close the socket in the method that opens it