managing closing socket