Proper way of shutting down the socket