If you must know how to avoid killing a person who is armed, you take fucking cover and tell them to surrender. There are many ways to do it but it always requires balls and nerves. It's also risky. The alternative is to kill.
Ya. most people are not ready for a gun fight if they are invaded. This means they don't wear bullet resistant clothing, they don't have proper cover with drywall, children may be in danger, ect..
this is Jeopardy, you know man.. My ballz of steel would shrivel and I would make a mess, sorry.
I would not make a sound to announce my presence, I would hit them with a gun light and shoot. The light would give me a fraction of a second for a visual target acquisition, as well as a second to know the intruder.
I would not shoot an innocent teen in the wrong house, I would give the purp. enough time so I can partially know the intentions of who is about to be killed. I would evaluate for 0.5 seconds with a blinding light in their eyes, before the worst. That is all I can offer.