use unload over beforeunload