Disconnect the client when the application is closed.
435963
@Override
    public void stop() {
        System.out.print("Stopping the client...");
        client.disconnect();
        System.out.println("done");
    }
435552
def stop_app(self):
        """"""
        try:
            if self._conn:
                # Be polite; let the dest know we're shutting down.
                try:
                    self.closeSl4aSession()
                except:
                    self.log.exception('Failed to gracefully shut down %s.',
                                       self.app_name)

                # Close the socket connection.
                self.disconnect()
                self.stop_event_dispatcher()

            # Terminate the app
            self._adb.shell('am force-stop com.googlecode.android_scripting')
        finally:
            # Always clean up the adb port
            self.clear_host_port()
791556
public void disconnect() {
        if (socket != null) {
            try {
                socket.close();
            }
            catch (IOException ioe) {

                // Does not matter, I guess.
            }
            socket = null;
        }
        connected = false;
    }
585777
protected void disconnect() {
		if (channel != null) {
			try {
				channel.close();
			} catch (Throwable cause) {
				logger.warn("Unexpected error occurred while closing AMQP channel!", cause);
			} finally {
				channel = null;
			}
		}
		if (client != null) {
			try {
				client.close();
			} catch (Throwable cause) {
				logger.warn("Unexpected error occurred while closing AMQP client!", cause);
			} finally {
				client = null;
			}
		}
	}
1156553
def disconnect(self):
        
        if self.connected:
            self._socket.close()
            self._socket = None
            self.connected = False
572682
def stop(self):
        """"""

        if self._disconnector:
            self._disconnector.stop()

        self.client.disconnect()
623530
static public void shutdownQuietly(HttpClient http) {
        if (http != null) {
            try {
                http.getConnectionManager().shutdown();
            } catch (Exception ignore) {
                // do nothing
            }
        }
    }
1251978
def closed(self, reason):
        """"""
        self.server.remove_connection(self)
        self.protocol.connection_lost(reason)
        if not isinstance(reason, ConnectionClosed):
            logger.warn("connection closed, reason: %s" % str(reason))
        else:
            logger.info("connection closed")
1265595
public void disconnect() throws Exception {

        if (connection != null) {
            try {
                if (connection instanceof Closeable) {
                    ((Closeable) connection).close();
                } else {
                    try {
                        connection.getInputStream().close();
                    } catch (IOException e) {
                        // ignore
                    }

                    try {
                        connection.getOutputStream().close();
                    } catch (IOException e) {
                        // ignore
                    }
                }
            } finally {
                connection = null;
            }
        }
    }
1249985
public void clientDisconnect()
  {
    try {
      OutHttpApp responseStream = _responseStream;
      
      if (responseStream != null) {
        responseStream.close();
      }
    } catch (Exception e) {
      log.log(Level.FINER, e.toString(), e);
    }
    
    ConnectionTcp conn = connTcp();

    if (conn != null) {
      conn.clientDisconnect();
    }

    killKeepalive("client disconnect");
  }
494931
def on_close(self):
        '''
        
        '''

        if self.id in self.funcserver.websocks:
            self.funcserver.websocks[self.id] = None
            ioloop = tornado.ioloop.IOLoop.instance()
            ioloop.add_callback(lambda: self.funcserver.websocks.pop(self.id, None))

        psession = self.funcserver.pysessions.get(self.pysession_id, None)
        if psession:
            psession['socks'].remove(self.id)
            if not psession['socks']:
                del self.funcserver.pysessions[self.pysession_id]
1085
def _disconnect(self, exc_info=False):
        """"""
        if self._stream:
            self._stream.close(exc_info=exc_info)
136887
def close(self):
        
        if self.closed is False:
            self._client.close()
            self.closed = True
            if self.debug is True:
                print('close')
        if self.debug is True:
            print("closed")
1031766
private void disconnect(AFTPClient client) {
	try {
	    if (client != null && client.isConnected()) {
		client.quit();
		client.disconnect();
	    }
	}
	catch (IOException ioe) {}
    }
233494
public void close() {
    try {
      if (conn != null) {
        conn.close();
      }
    } catch (IOException ignored) { }

    if (zkClient != null) {
      zkClient.stopAndWait();
    }
  }
1233781
public synchronized void close() throws IOException {
        if(getStatus().equals(ConnectionStatus.CLOSED)){
            return ;
        }
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Closing client for session: 0x"
                      + getSessionId());
        }
        connectRun.set(false);

        try{
            clientSocket.cleanup();
        }catch(Exception e){
            LOGGER.warn("Close the WSDirectorySocket get error.", e);
        }

        try {
            setStatus(ConnectionStatus.CLOSED);
            sendCloseSession();
            closeSession();
            eventThread.queueEventOfDeath();
        } catch (ServiceException e) {
            LOGGER.warn("Execute the CloseSession Protocol failed when close", e);
        }
    }
888724
def _disconnect(self):
        
        try:
            self._connection.close()
            logger.debug("Disconnected from rabbit")
        except Exception:
            logger.exception("Unable to close connection")