fixed issue #6. Clients now unregister when the socket closes