Handle the "onbeforeunload" event when the editor is "dirty". Fixes #3