added the closing of socket.