@jezwn I personally wouldn't rely on window.onunload because there will
always be race conditions between your code getting executed vs the
browser navigating away. Maybe it works for you, but it might not with
your users. But if you find that your method works, then go ahead, and I
suggest that you document it clearly, because it's definitely out of the
ordinary.