should be window.onbeforeunload = xyz. However in this case, it's not needed anyway since we are only adding the event listener once on page load, which already gets cleared when you reload the page.
should be window.onbeforeunload = xyz. However in this case, it's not needed anyway since we are only adding the event listener once on page load, which already gets cleared when you reload the page.