Fix onunload event for js