Clean up the child procress and socket.
@throws IOException
2113
void cleanup() throws IOException {
    serverSocket.close();
    try {
      downlink.close();
    } catch (InterruptedException ie) {
      Thread.currentThread().interrupt();
    }      
  }
285325
@Override
	@SuppressWarnings("resource")
	public void close() throws IOException {
		flush();

		if (this.tempStream != null) {
			this.tempStream.close();
			this.tempStream = null;
		}

		if (this.stream != null && this.stream.isOpen()) {

			// Copy the channels
			if (this.buffer != null && this.tempFile != null) {
				try {
					try (ReadableByteChannel in = Channels.newChannel(new FileInputStream(this.tempFile))) {
						final ByteBuffer hbuffer = ByteBuffer.allocate(100);
						in.read(hbuffer);

						hbuffer.limit(100);
						hbuffer.position(6 * 4);
						hbuffer.order(ByteOrder.BIG_ENDIAN);
						hbuffer.putInt(toESRIWords(this.bufferPosition));
						hbuffer.rewind();
						this.stream.write(hbuffer);

						int nbRead;
						this.buffer.rewind();

						while ((nbRead = in.read(this.buffer)) >= 0) {
							this.buffer.rewind();
							this.buffer.limit(nbRead);
							this.stream.write(this.buffer);
							this.buffer.rewind();
							this.buffer.limit(this.buffer.capacity());
						}
					}

				} finally {
					this.tempFile.delete();
					this.tempFile = null;
				}

			}
			this.stream.close();
		}
	}
1165946
public void cleanUp() {
    if (outSocket != null) {
      try {
        outSocket.close();
      } catch (Exception e) {
        LogLog.error("Could not close outSocket.", e);
      }

      outSocket = null;
    }
  }
1232177
synchronized void cleanUp() {

        updateAccessCounts();

        int                          removeCount = size() / 2;
        int accessTarget = getAccessCountCeiling(removeCount, removeCount / 8);
        BaseHashMap.BaseHashIterator it          = new BaseHashIterator();
        int                          savecount   = 0;

        for (; it.hasNext(); ) {
            CachedObject r = (CachedObject) it.next();

            if (it.getAccessCount() <= accessTarget) {
                synchronized (r) {
                    if (!r.isKeepInMemory()) {
                        r.setInMemory(false);

                        if (r.hasChanged()) {
                            rowTable[savecount++] = r;
                        }

                        it.remove();

                        cacheBytesLength -= r.getStorageSize();

                        removeCount--;
                    }
                }
            }
        }

        if (removeCount > 50) {
            it = new BaseHashIterator();

            for (; removeCount >= 0 && it.hasNext(); ) {
                CachedObject r = (CachedObject) it.next();

                if (!r.isKeepInMemory()) {
                    r.setInMemory(false);

                    if (r.hasChanged()) {
                        rowTable[savecount++] = r;
                    }

                    it.remove();

                    cacheBytesLength -= r.getStorageSize();

                    removeCount--;
                }
            }
        }

        super.setAccessCountFloor(accessTarget);
        saveRows(savecount);
    }
1051308
def clean_up(self):
        '''  '''
        self.socket.close()
        for h in self.capture_handlers:
            h['logger'].close()
684461
public void remove() throws IOException
   {
      if ((fileBuffer != null) && PrivilegedFileHelper.exists(fileBuffer))
      {
         if (!PrivilegedFileHelper.delete(fileBuffer))
         {
            throw new IOException("Cannot remove file " + PrivilegedFileHelper.getAbsolutePath(fileBuffer)
               + " Close all streams.");
         }
      }
   }
476387
public synchronized void flush() throws IOException {
    this.inner.write(this.remainder.getBytes());
    this.inner.flush();
    this.remainder = Bits.NULL;
  }
12973
public void close() throws IOException {
        if(inp != null)
            inp.close();
        if(out != null)
            out.close();
    }
274154
public synchronized void clear() {
		try {
			this.storage.close();
			this.storage = provider.createStorage();
		} catch (IOException e) {
			// major fuckup
			e.printStackTrace();
		}
		this.size = 0;
	}
1202783
synchronized void clear() throws IOException
   {
      if (out != null)
      {
         out.close();
         out = null;
      }
      try
      {
         if (dir.fileExists(REDO_LOG))
         {
            dir.deleteFile(REDO_LOG);
         }
      }
      catch (IOException e)
      {
         log.error(e.getLocalizedMessage(), e);
         throw e;
      }
      entryCount = 0;
   }
279177
public void clear() {
        while (tail != head) {
            hpackHeaderFields[tail++] = null;
            if (tail == hpackHeaderFields.length) {
                tail = 0;
            }
        }
        head = 0;
        tail = 0;
        size = 0;
    }
1151265
private void _cleanChildren() {
        //bStatsTreeNeedsUpdate = true;
        if (children != null) {
            Iterator values = children.values().iterator();

            while (values.hasNext()) {
                ModuleItem remMI = (ModuleItem) values.next();
                remMI.getInstance().cleanup();

                //_cleanMBean(remMI);
                remMI._cleanChildren();
                remMI = null;
            }

            children.clear();
        }
    }
195168
@Override
    synchronized public void cleanup() {
        LOGGER.info("Cleanup the DirectorySocket.");

        if(task != null){
            task.toStop();
            task = null;
        }

        if(client != null){
            try {
                client.stop();
            } catch (Exception e) {
                LOGGER.warn("Close WebSocketClient get exception.", e);
            }
            client = null;
        }

        try {
            if(session != null){
                session.close();
            }
        } catch (IOException e) {
            LOGGER.warn("Close the WebSocket Session get exception.", e);
        }

        if(sessionFuture != null){
            try {
            sessionFuture.cancel(true);
            } catch (Exception e) {
                // do nothing
            }
        }

        session = null;
        sessionFuture = null;
        websocketStarted = false;
        connected = false;
        isStarted = false;
    }
390578
private void clear() {
        if (null != this._output) {
            for (int i = 0; i < this._output.length; i++) {
                if (null != this._output[i]) {
                    this._output[i].release();
                    this._output[i] = null;
                }
            }
        }
        this.outputIndex = 0;
        this.bufferedCount = 0;
        this.bytesWritten = 0L;
        this.setWriteListenerCallBack(null);
    }
1270579
@Override
    public void clear() {
        if (null != this.output) {
            for (int i = 0; i < this.output.length; i++) {
                if (null != this.output[i]) {
                    this.output[i].release();
                    this.output[i] = null;
                }
            }
        }
        this.outputIndex = 0;
        this.bufferedCount = 0;
        this.bytesWritten = 0L;
        this.isClosing = false;
    }
466969
@SuppressWarnings({ "rawtypes", "unchecked" })
    private void cleanupSessions(List<String> storeNamesToCleanUp) {

        logger.info("Performing cleanup");
        for(String store: storeNamesToCleanUp) {

            for(Node node: nodesToStream) {
                try {
                    SocketAndStreams sands = nodeIdStoreToSocketAndStreams.get(new Pair(store,
                                                                                        node.getId()));
                    close(sands.getSocket());
                    SocketDestination destination = nodeIdStoreToSocketRequest.get(new Pair(store,
                                                                                            node.getId()));
                    streamingSocketPool.checkin(destination, sands);
                } catch(Exception ioE) {
                    logger.error(ioE);
                }
            }

        }

        cleanedUp = true;

    }
205300
private void cleanup() {
    if (operation instanceof Command && log.isOpen()) {
      try {
        log.release(index);
      } catch (IllegalStateException e) {
      }
    }

    session.release();

    index = 0;
    session = null;
    instant = null;
    operation = null;

    pool.release(this);
  }