To elaborate a bit on the ‘horrible UX’ part:
‘Before you leave, […]’ — No, you do not have the right to tell me what I have to do when I leave your site. My intention was to close the tab, not to star your project on GitHub!
I created glio.js, and yeah. I'm wrong about the text that was chosen in the modal popup. But, the 'Top-Direction' seems the user will leaves your site, tab... But the principal idea is trigger a callback when this happens.