Adding beforeunload Event