Harden your perimeter
Hear, hear! to everything Uncle Buck and jhenry said, plus:
If you have enough foresight to consider such situations, then you have the foresight to invest in perimeter protection that makes such situations less likely, e.g., a dog, a competent and defeat-resistant alarm system (including annunciators for your driveway and other approaches), better locks and physical barriers, and a security-driven family routine.
Your gun is the bottom line and last resort in home defense. Everything else should be geared to avoiding and preventing a situation you have to shoot your way out of.