only ask beforeunload if the user has unsaved work, not always