Can I shoot someone invading my home?
If they are threatening you or others with violence and you (and the other threatened persons) cannot reasonably get away, you can always shoot. If you can retreat, in the majority of states, you could still shoot an intruder threatening violence in your own home, but not in all states. If in doubt about your state's law, retreat if possible.
"A man's home is his castle" is an old saying which has been embraced, to a greater or lesser extent, by most (but not all) U.S. states. It plays out in what is called the "Castle Doctrine" or "Stand-Your-Ground" laws. To understand them, you have to understand the law of self-defense generally, as well as how that plays out where there are no Castle or Stand-Your-Ground laws.
As a general matter, lethal force--and for this purpose, a gun is always considered lethal force--may only be used when there is a credible (that is, believable) and imminent (or immediate) threat of severe injury or death to yourself or another person. Think of this as the rule of proportionality: the force you may use to defend yourself or others must be proportionate to the threat you are defending against. Someone saying that they're going to get you "later" is not an immediate or imminent threat--you have time to call the police, and so cannot respond with force on the spot. A frail 110-pounder person who is unarmed threatening immediate violence against a healthy 200-pound person is not a credible threat of severe injury. It's highly unlikely that someone can inflict serious injury on another person nearly double their mass. You have to look to the context, to see if the threat is real and immediate; if it's not, you can't shoot.
There are other limitations, too, on your ability to use lethal force (i.e., shoot):
(1) The confrontation must not have stopped--even if there had been a credible threat of imminent serious bodily harm, if the attacker gave up and is now trying to flee or leave, you can't shoot them.
(2) You cannot have provoked the attack in order to have an excuse to shoot, such as by harassing the other person, threatening him or her, or withholding his or her property. And
(3) In the past, you always had to try to "retreat"--that is, get away without fighting if such was reasonable possible. It's this last requirement or limitation which has changed in most states.
It was always the case that if you or the person(s) you were protecting could not reasonably retreat or escape, you could shoot the attacker. But many states have decided that you should not have to retreat from your own home. Therefore, they passed various versions of the Castle Doctrine and Stand-Your-Ground laws, which in different ways (each state has its own laws; these laws are not uniform) state that if you are faced with a credible, imminent threat of serious injury in your home, then so long as you did not provoke it, you may shoot without having to try to get away first.
Since not all states have these laws, and since these laws are not identical in the states which have them, if you have a gun, it makes good sense to look up your specific state's law(s) on the subject and make sure you understand them. Violating these laws could mean that what you thought was self-defense was not, and you face liability for (depending on outcome) assault, attempted murder, or even manslaughter or murder.
And focus on a key element: even under the Castle Doctrine and Stand-Your-Ground laws, there must be a threat of violence. An obnoxious intruder who poses no reasonable or credible threat may not be shot, no matter how much you want them gone, how often you asked them to leave, or how many times they refused to go. Instead, call the police and have them picked up for trespassing.