Override window.onbeforeunload event