"If the person you're fighting has a gun and all you have is your fists, you lose."
This statement is not entirely true, but it's so close as to make little difference. Against a knife, you can improvise a weapon fairly quickly and even the balance. Grab a chair, a seat-cushion, a crochet hook (that last not a recommended choice), a garbage can, a handful of rocks--anything which will extend your reach or protect your body. Attack vital targets without mercy. Or just run.
These are not options against a handgun. In that situation you're far more likely to need to find hard or soft cover, or to perform one of those nifty disarms all the cool kids have been talking about (you know, the kind that'll get you eviscerated against a knife if you haven't been practising them every day for the past ten years. Stick with running, finding a bat, and then hitting the person until they drop the knife and/or stop moving except for the occasional twitch). Remember the example of Mr. Curry, who survived by keeping a tree between his opponent and him.
Practising handgun disarms, I had a tendency to cheat back, away from the shooter. Against a knife, any additional distance is advantageous. But against a handgun, that additional distance is what's keeping you from getting the handgun away from them. It's slowing you down, and not making any difference on how quickly they can pull the trigger. In fact, if you're being held at gunpoint, you might as well try to get them to press the barrel against you. You'll be dead just as quickly as if they were ten feet away, and you'll get some tactial feedback when you move to take the handgun away.
The cheating which was such a disadvantage for me can be used to close the distance, however. In fencing one can perform a false advance, by lifting the front foot without moving the rear. While one's body moves backwards, the actual distance one can cover with a lunge has not changed. The opponent may be lured in, and an attack arrive. I am not suggesting a sudden fencing lunge is the way to deal with someone holding a handgun one. Rather, if one has seemed to move back, the assailant will tend to close the distance. At this point one can return to the original stance, having gained a few vital inches. From this position one can make an attack against the assailant and attempt to take the handgun away.
Always push the handgun to the outside--that is, not across your body or the assailant's. The need to avoid pushing it across your body should be obvious. The advantage of pushing it to the outside of the assailant is that the handgun is less likely to accidentally discharge. As you move your hands in to bring the gun off-line, twist your body so that you gain safety that way as well. Performing both motions (hand and body) simultaneously doubles the distance you gain. Talk before you do this--say anything. If you can get your assailant to think, to try to puzzle out the meaning of what you've just said, ("Okay, but my cousin's coming for dinner, so..."), you'll have decreased their response time and increased your chances. You want them thinking about what you're saying, not about what you might be about to do.