Shooting someone in self defense will usually not land you in jail as long as the shooting was justifiable and you can prove it.
If someone tries to beat you up for example then you usually cannot shoot the person but if the person is trying to stab you or shoot you then you can shoot the person to end the threat.
Just don't shoot the person more than once or more than you need to so you can stop the threat.
As soon as the threat has stopped after shooting the person you should not shoot them anymore otherwise it can be deemed murder if the person dies.
If someone is just trying to beat you up then you can use your own fists etc to fight back but don't try to stab the person or shoot them unless you have to as a last resort.
If the person is beating you up and you cannot stop the threat and you feel that you're gonna be beaten to death then you may need to shoot them and in that case it would be justifiable.