For different shooting situations and different people, using a rifle, shotgun or pistol is up to that individual. In other words, the ultimate decision about which firearm to use rests with the shooter. The key is to practice and become competent with whatever firearm you plan to use for home defense or personal protection. Look your particular situation over and think about what you should do and which firearm would be best for your location and situation.
If you live in an apartment building then maybe a shotgun would be better for you to use than an AK type rifle in 7.62 X 39. If you live in a rural setting, then maybe a good 7.62 X 39 AK type rifle might be the gun you should consider. And in either case, consider backing up the primary rifle or shotgun with a decent pistol of some sort. But no matter what, which ever you decide to use you should practice with it a lot and you should become very, very competent with your primary and your secondary firearm. You should be able to transition back and forth between them with no problem.
So, you've made up your mind, practiced a lot with your primary and secondary firearm and then
"something happens" to change your shooting needs and defensive decisions. Can you change which firearm you use? Should you change firearms to reflect a change in the situation or try to push on through with what you have? If you have something pop up that needs you to switch off,
you should already be prepared for that scenario too. In other words, don't plan for just one situation with one weapon. Practice with several different firearms so that you're comfortable and capable with a number of your firearms.
If you have one guy with which to contend, a shotgun will probably do you right and stop him cold. If, however, you suddenly are confronted with 25 or more looters, rioters and rapists coming straight for your front door, maybe the rifle might be a better tool to bring to bear here. If you have practiced with both your shotgun and your rifle then you already know how to use both or either one as needed and how to transition with either one with the pistol you also carry. So have more than just one plan in place to cover your shooting needs.