Cleans up sockets properly when disconnected