prevent uncaught 'beforeunload is not available in packaged apps'