add beforeunload handler to make sure all tokens destroyed sanely