I used to arrange (finance) gap insurance years ago. It often lost money for the insurance company! But that was also a function of the absolutely outrageous commission earned by dealers on it.
Selling of gap by most of the gap insurers has been suspended by the FCA due to this commission.
So, if you can buy it at the right price then it’s worth having. When I had a leased car I bought lease gap from ALA. There are other providers and this has been discussed on here before (good luck!). I’ve never claimed on it so no recommendations there. I think I originally got the ala name from asking on here.
There are different types, from finance gap (pays difference between motor insurance settlement and amount remaining on finance) to lease gap (pays remaining lease payments IIRC) to “return to invoice” gap which can pay back to your original purchase price. That might be the one you want, but from memory it’s the most expensive.