add delay to autosave in beforeunload

allows forceful 'discard changes' by reloading the page and dismissing the warning,
which @fperez really wanted today.
Merge pull request #3732 from minrk/slow-save-on-close

add delay to autosave in beforeunload

allows forceful 'discard changes' by reloading the page and dismissing the warning.
The timer doesn't start until after the dialog is dismissed, so if you decide to nav away without saving changes, the changes will actually not be saved.