Added method to close the socket