Use beforeunload for informing that user has closed the chat