needed so i can handle the closing event on the client
Server code needed for cleanup