Can you disable an attacker with a gun?
Yes, you certainly can. There's plenty of places on the human body that can incapacitate the attacker in a non-lethal manner when shot (if you have to shoot at all). A gun is as good for self-defense as any other method/tool.
If somebody says it's impossible to defend with a gun, I'd say that they're dead wrong.
Something designed with the intent to kill in mind (firearms) can only be considered offensively or defensively utilized depending on the situation at hand and the motives of the shooter.
On the legal side, not all states and countries have the castle doctrine (allowing you to shoot and defend yourself without much, if any, trouble with the law if somebody intrudes your house) or similar laws. Some places of the world may even be as asinine as to charge you (the victim, if you aren't the perpetrator) with assault for daring to defend yourself against criminal scum. Bollocks to those rules, I say. But, unfortunately, if you have those pro-criminal laws in place then you turn into the new bad guy and any method of self-defense that you may utilize turns into a method of assault that you can and will be charged with.
So all in all, it boils down to your philosophy and the laws in effect in your state/country.
From the sounds of it, you are able to defend yourself with a gun and say as such.
captcha: well read
Why thank you, captcha.