Whether you go to jail for killing someone in self defense or not will depend on whether or not the self defense killing was justified.
In most places the law about killing for self defense says that you have a duty to retreat first before resorting to harming or killing someone in self defense.
So for example if someone is just wanting to fight you or has a knife and threatens you with the knife and you can safely retreat somewhere such as in your house or vehicle out of harms way and call the police then that may cause you to be arrested if you just stood there and shot the person in self defense.
You might still be able to prove to the judge that the killing was justified but you may be arrested so be prepared for that.
But if you have to choose between protecting yourself and going to jail when your life really is in danger then it would be better to get arrested and be alive then not stop the threat and be dead.
But you should only shoot to kill someone in self defense if your life really is in danger such as if someone pulls a gun on you and tries to shoot you.
Then you could more prove that the killing in self defense was justified.
It's also a good idea to have a camera such as a go pro camera that you can instantly command to come on and record so that you can use the film to prove what happened.