It depends on where you live. If you live in Joysey or NY, Mass, Conn etc chances are you are gonna get charged even if they are there with flame throwers, bombs, chainsaws, machineguns etc.
Around here in South Carolina there has been a couple home invasions in last year or so and when deputies got there they found the perps dead. No charges filed.
You can pretty well figure if you live in a state that votes democrat you are gonna be seen as a war monger or some other thing like a church goer etc and they will come after you.
A handgun regardless of caliber cannot be depended up to take bad guys down immediately even with a lethal hit. A shotgun is best indoors followed by a 30 cal rifle and I don't mean M1 Carbine but a real 30 cal like 30.06, 308 etc. I am not aware of anyone that survived a thoracic cavity solid hit and lived to tell the tale.
I just remembered some advise I got from a couple NY cops who I was in Smith & Wesson Armorer's School with 30 years ago. I was joking around with them and told them when I went to the city I carried a 25 auto and they said basically, "If you use it don't hang around till we get there because if you do you will deserve what you get." They went on to explain they find about 50 people a day dead in NYC and it is just another form to fill out unless some jerk is standing there crying saying he did it.