Fixes possible memory leak in the chat rooms when the user leaving or destroying the chat room.