Addendum to #286

Forgot to check if we need to save in beforeunload event