restore "unsaved changes" warning on unload

Autosave is triggered at this event, but it seems to fail sometimes (perhaps when it's too slow?).

This restores the "beforeunload" warning message, informing the user that unsaved changes may be lost.
It still triggers an autosave (assuming autosave is enabled), in which case the message is "Autosave in progress".

closes #3475