Changed beforeunload event to unload event

Removes the flash of misaligned content when unloading gradeView