Yeah. We did a thing on gun disarms ages ago, though the quick takeaway is, they are extraordinarily dangerous. You can find the original answer here.
For “defeating” someone with a gun, you might be talking more about the element of surprise, and negating the weapon. Attacking the gunman while they’re not aiming at you, will do wonders for your own survival, even if it means someone else getting shot in the process. This may or may not be a sacrifice your character is willing to make.
If the weapon is inoperable, or empty, it creates a similar opening. It’s worth noting that most mass shooters in the US end up being taken down while trying to reload their weapons. It’s a disturbing thing to think about, but someone who’s emptied their weapon, and was never properly trained to reload quickly, is most vulnerable when their weapon is empty. High capacity magazines tend to be more prone to jamming, which is what happened in Aurora, Colorado, as I recall.
It’s also worth remembering that the fifth death in the Vegas shooting was a civilian that tried to intervene with their concealed carry. So, from pretty much every front, these are very dangerous situations.