Added Closing event for User and Close Chat button for the chat.

The Close Chat button in the chat allows the user to close the
connection fom the chat screen, with it, I added an onClose method in
the client-side code, which closes all event listeners before closing
the connection, thus avoiding messages to be sent twice when the user
logs off and on again using the close button.