Destructor.  Call this to gracefully terminate context and close any managed 0MQ sockets
344754
public void destroy()
    {
        for (Socket socket : sockets) {
            destroySocket(socket);
        }
        sockets.clear();

        for (Selector selector : selectors) {
            context.close(selector);
        }
        selectors.clear();

        // Only terminate context if we are on the main thread
        if (isMain()) {
            context.term();
        }
    }
317024
public void terminate()
    {
        try
        {
            in.close();
        }
        catch (final IOException exception)
        {
            Verbose.exception(exception);
        }
        try
        {
            out.close();
        }
        catch (final IOException exception)
        {
            Verbose.exception(exception);
        }
        try
        {
            socket.close();
        }
        catch (final IOException exception)
        {
            Verbose.exception(exception);
        }
        state = StateConnection.DISCONNECTED;
    }
527641
public void close()
    {
    if (_socket!=null) {
        try {
        _socket.close();
        _socket = null;
        } catch (IOException e) {
        System.err.println("Exception: " + e);
        // throw new SoccomException(SoccomException.RECV_ERROR);
        }
        _in = null;
        _out = null;
    }
    }
797827
@Override
    public void close() throws IOException {
        dispose();

        if(socket != null) {
            socket.close();
            socket = null;
        }
    }
664103
def exit(self):
        
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.connect((self.server2, self.port2))
        self._hello(sock)

        comms.send_message(sock, ("<Exit>" + self._get_token() + "</Exit>").encode())
        reply = comms.recv_message(sock)
        sock.close()
        ok, = struct.unpack('!I', reply)
        return ok != 0
155512
function disposeOfSocket(apiBase) {
        return function (error) {
            loggingService.warn("Got disconnected from signalling server (" + apiBase + ")", error);

            var socket = connectedSockets[apiBase];
            if (socket) {
                stopConnectivityChecks();
                socket.removeAllListeners();
                socket.io.removeAllListeners();
                try {
                    socket.disconnect();
                }
                catch (ignore) {
                }
                deleteSocket(apiBase);

                if (!unloadInProgress) {
                    connectAndMonitor();
                }
            }
            else {
                throw new Error("BUG ::: Disconnected from a socket we're not connected to?!");
            }
        };
    }
1251653
def close(self, **kwargs):
        
        self.keep_running = False
        if self.sock:
            self.sock.close(**kwargs)
            self.sock = None
864031
def close(self):
        
        if self._protocol is not None:
            self._protocol.processor.close()
            del self._protocol
702743
function close() {
  log.notice('removing the unix socket file')
  try {
    fs.unlinkSync(file);
  }catch(e){} // nothing to do at this point

  Server.prototype.close.call(this);
}
1009563
function destroy () {
    if (this.connection.destroy) {
      this.connection.destroy()
    } else if (this.connected) {
      this.connection.disconnect('destroy')
    }
    for (var i = 0; i < this.unbind.length; i++) {
      this.unbind[i]()
    }
    clearTimeout(this.pingTimeout)
    this.endTimeout()
  }
1129613
public void destroy() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "destroy");
        }

        // Go through the hashtable and destroy all long-lived, single instance,
        // resources related to a given TCP Channel type (NIO, AIO, etc...)
        for (ChannelTermination ct : this.terminationList.values()) {
            ct.terminate();
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "destroy");
        }
    }
751227
private void close(String command, Socket socket) throws IOException {
        lock.lock();
        try {
            String token = command.substring(closeTagLength, command.length() - (closeTagLength + 1));

            initTokens.remove(token);

            DataOutputStream dout = new DataOutputStream(socket.getOutputStream());
            dout.writeInt(BYTES_INT);
            dout.writeInt(1);
            dout.flush();
        } finally {
            lock.unlock();
        }
    }
556476
def close(self):
        
        if not self.active:
            return
        self.stop_thread()
        for chan in list(self._channels.values()):
            chan._unlink()
        self.sock.close()
735338
function dispose() {
                if (!this.disposed) {
                    this.messageChannel.dispose();
                    this.messageChannel = void 0;
                    this.eventChannel = void 0;
                    this.mapper = void 0;
                    this.callbackCache = void 0;
                    this.circuit = void 0;
                    this.disposed = true;
                }
            }
1200175
protected synchronized void destroyServerSocket() {
        if (null == this.serverSocket) {
            // already closed
            return;
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "ServerSocket being closed for port " + this.listenPort);
        }
        closeServerSocket();
        this.serverSocket = null;
    }
1348060
def remove(socket)
      ptr = ptr_for_socket(socket)
      rc = ZMQ.poller_remove(@poller_ptr, ptr)
      HasFFIDelegate.raise_zmq_err if rc == -1
      forget_socket(socket)
    end
1176104
void killSocket() {
        try {
            m_closing = true;
            m_socket.setKeepAlive(false);
            m_socket.setSoLinger(false, 0);
            Thread.sleep(25);
            m_socket.close();
            Thread.sleep(25);
            System.gc();
            Thread.sleep(25);
        }
        catch (Exception e) {
            // don't REALLY care if this fails
            e.printStackTrace();
        }
    }