Remove calling socket.close twise