Misclicks are bound to happen, especially when you have a lot of browser tabs open. I propose that the tab close confirmation thing in most browsers gets triggered when there are unsaved changes, to prevent loss of data.
I have learned this feature is not already in Caps the hard way.
I don't know what it's called exactly, so here's a screencap of one for example: