It entirely depends on what product you've chosen as to what it does.
Some GAP insurance will bridge the gap between the payout from your insurer and the amount you owe on finance. So if you are a complete donut and you finance a car 100% which you crash a year later owing £15k on a car worth just £11k, the GAP insurance will pay the extra £4k to clear the finance. This is idiot-gap insurance because it's for people foolish enough to buy a car using so much finance that they enter negative equity. This is a completely stupid thing to do anyway, best thing to do here is to buy smart in the first place not insure yourself against your own financial stupidity
You can also get Return to Invoice GAP, which pays you the difference between what the payout from the insurer is, and what you paid for your car originally. This is a far better, far more useful product that can be of real benefit even if you don't fail at buying cars. Effectively it means if you always buy 2 year old Audi's and you write it off 2 years later, you can go and buy another 2 year old Audi instead of having to buy a 4 year old one with the insurers payout.