Close current index and free resources
546493
private function _close()
    {
        if ($this->_closed) {
            // index is already closed and resources are cleaned up
            return;
        }

        $this->commit();

        // Release "under processing" flag
        Zend_Search_Lucene_LockManager::releaseReadLock($this->_directory);

        if ($this->_closeDirOnExit) {
            $this->_directory->close();
        }

        $this->_directory    = null;
        $this->_writer       = null;
        $this->_segmentInfos = null;

        $this->_closed = true;
    }
845484
def _Close(self):
    """"""
    self._cpio_archive_file_entry = None
    self._cpio_archive_file = None

    self._file_system.Close()
    self._file_system = None
1051178
@Override
	public void close() {

		// copy all resources as the close of a resource modifies the
		// xaresources ...
		Set<PhynixxXAResource<T>> tmpXAResources = new HashSet<PhynixxXAResource<T>>();
		synchronized (xaresources) {
			if (this.xaresources.size() > 0) {
				tmpXAResources.addAll(xaresources);
			}
		}
		// close all reopen XAResources ....
		for (Iterator<PhynixxXAResource<T>> iterator = tmpXAResources.iterator(); iterator.hasNext();) {
			PhynixxXAResource<T> xaresource = iterator.next();
			xaresource.close();
		}

		this.getXATransactionalBranchRepository().close();
	}
1354297
@Override
  public void close()
  {
    super.close();
    facts.clear();
    indexAndOffsets.clear();

    if (selectors != null) {
      selectors.clear();
    }

    Closer c = Closer.create();
    aggBuffers.forEach(c::register);
    try {
      c.close();
    }
    catch (IOException e) {
      throw new RuntimeException(e);
    }
    aggBuffers.clear();
  }
679787
public void close() {
		if (blk != null) {
			tx.bufferMgr().unpin(currentBuff);
			blk = null;
			currentBuff = null;
		}
	}
657003
private void cleanUpSource() {
		SoundStore store = SoundStore.get();
		
		AL10.alSourceStop(store.getSource(0));
		IntBuffer buffer = BufferUtils.createIntBuffer(1);
		int queued = AL10.alGetSourcei(store.getSource(0), AL10.AL_BUFFERS_QUEUED);
		
		while (queued > 0)
		{
			AL10.alSourceUnqueueBuffers(store.getSource(0), buffer);
			queued--;
		}
		
		AL10.alSourcei(store.getSource(0), AL10.AL_BUFFER, 0);
	}
482423
def close(self):
        
        try:
            logger.debug('Closing ResourceManager (session: %s)', self.session)
            # Cleanly close all resources when closing the manager.
            for resource in self._created_resources:
                resource.close()
            self.visalib.close(self.session)
            self.session = None
            self.visalib.resource_manager = None
        except errors.InvalidSession:
            pass
721547
def close(self):
        
        # This may not be absolutely necessary, but it is safe.
        # It's the closest thing to a close() method.
        if self._dev is not None:
            usb.util.dispose_resources(self._dev)
            self._dev = None
385477
def close(self):
        """"""
        # free parsed data
        if not self.is_opened():
            return
        self.__open_status = False

        # abort all running threads first
        if self.__reading_thread and self.__reading_thread.is_alive():
            self.__reading_thread.abort()

        #avoid posting new reports
        if self._input_report_queue:
            self._input_report_queue.release_events()

        if self.__input_processing_thread and \
                self.__input_processing_thread.is_alive():
            self.__input_processing_thread.abort()

        #properly close API handlers and pointers
        if self.ptr_preparsed_data:
            ptr_preparsed_data = self.ptr_preparsed_data
            self.ptr_preparsed_data = None
            hid_dll.HidD_FreePreparsedData(ptr_preparsed_data)

        # wait for the reading thread to complete before closing device handle
        if self.__reading_thread:
            self.__reading_thread.join()

        if self.hid_handle:
            winapi.CloseHandle(self.hid_handle)

        # make sure report procesing thread is closed
        if self.__input_processing_thread:
            self.__input_processing_thread.join()

        #reset vars (for GC)
        button_caps_storage = self.__button_caps_storage
        self.__reset_vars()

        while button_caps_storage:
            item = button_caps_storage.pop()
            del item
108735
public void close()
   {
      // stop index merger
      // when calling this method we must not lock this MultiIndex, otherwise
      // a deadlock might occur
      if (merger != null)
      {
         merger.dispose();
         merger = null;
      }
      
      synchronized (this)
      {
         try
         {
            // stop timer
            if (flushTask != null)
            {
               flushTask.cancel();
            }

            // commit / close indexes
            try
            {
               releaseMultiReader();
            }
            catch (IOException e)
            {
               LOG.error("Exception while closing search index.", e);
            }
            if (modeHandler.getMode().equals(IndexerIoMode.READ_WRITE))
            {
               try
               {
                  flush();
               }
               catch (IOException e)
               {
                  LOG.error("Exception while closing search index.", e);
               }
            }
            volatileIndex.close();
            for (int i = 0; i < indexes.size(); i++)
            {
               (indexes.get(i)).close();
            }

            // finally close directory
            try
            {
               indexDir.close();
            }
            catch (IOException e)
            {
               LOG.error("Exception while closing directory.", e);
            }
            modeHandler.removeIndexerIoModeListener(this);
            indexUpdateMonitor.removeIndexUpdateMonitorListener(this);
            this.stopped.set(true);
         }
         finally
         {
            // Remove the hook that will stop the threads if they are still running
            SecurityHelper.doPrivilegedAction(new PrivilegedAction<Object>()
            {
               public Void run()
               {
                  try
                  {
                     Runtime.getRuntime().removeShutdownHook(hook);
                  }
                  catch (IllegalStateException e)
                  {
                     // can't register shutdown hook because
                     // jvm shutdown sequence has already begun,
                     // silently ignore...
                     if (LOG.isTraceEnabled())
                     {
                        LOG.trace("An exception occurred: " + e.getMessage());
                     }
                  }
                  return null;
               }
            });
         }
      }
   }
1342123
private void closeRemoteResources() {
        if (reader != null) {
            try {
                reader.close();
            } catch (final IOException ignore) {
            }
            reader = null;
        }
        if (writer != null) {
            writer.close();
            writer = null;
        }
        if (socketOutstream != null) {
            try {
                socketOutstream.close();
            } catch (final IOException ignore) {
            }
            socketOutstream = null;
        }
        if (socketInstream != null) {
            try {
                socketInstream.close();
            } catch (final IOException ignore) {
            }
            socketInstream = null;
        }
        if (socket != null) {
            try {
                socket.close();
            } catch (final IOException ignore) {
            }
            socket = null;
        }
    }
198663
@Override
    public synchronized void close() {
        final int count = INSTANCE.usageCount.get() - 1;
        if (count <= 0) {
            INSTANCE.usageCount.set(0);
            if (searchingAnalyzer != null) {
                searchingAnalyzer.close();
                searchingAnalyzer = null;
            }
            if (indexReader != null) {
                try {
                    indexReader.close();
                } catch (IOException ex) {
                    LOGGER.trace("", ex);
                }
                indexReader = null;
            }
            queryParser = null;
            indexSearcher = null;
            if (index != null) {
                try {
                    index.close();
                } catch (IOException ex) {
                    LOGGER.trace("", ex);
                }
                index = null;
            }
        }
    }
1302481
private void deleteFreeLink(int index)
    {
        this.base.set(-this.check.get(index), this.base.get(index));
        this.check.set(-this.base.get(index), this.check.get(index));
    }
239267
def close(self):
        
        resource = ResourceLocator(CommandShell.ShellResource)
        resource.add_selector('ShellId', self.__shell_id)
        self.session.delete(resource)
735432
@SuppressWarnings("unchecked")
   void dispose()
   {
      log.debug("dispose IndexMerger");
      // get mutex for index replacements
      try
      {
         indexReplacement.acquire();
      }
      catch (InterruptedException e)
      {
         log.warn("Interrupted while acquiring index replacement sync: " + e);
         // try to stop IndexMerger without the sync
      }

      // clear task queue
      mergeTasks.clear();

      // send quit
      mergeTasks.add(QUIT);
      log.debug("quit sent");

      try
      {
         // give the merger thread some time to quit,
         // it is possible that the merger is busy working on a large index.
         // if that is the case we will just ignore it and the daemon will
         // die without being able to finish the merge.
         // at this point it is not possible anymore to replace indexes
         // on the MultiIndex because we hold the indexReplacement Sync.
         this.join(500);
         if (isAlive())
         {
            log.info("Unable to stop IndexMerger. Daemon is busy.");
         }
         else
         {
            log.debug("IndexMerger thread stopped");
         }
         log.debug("merge queue size: " + mergeTasks.size());
      }
      catch (InterruptedException e)
      {
         log.warn("Interrupted while waiting for IndexMerger thread to terminate.");
      }
   }
45439
protected static void blockAndReleaseAllCloseableResources()
    {
        synchronized(CloseableResourceManager.class)
        {
            //set flag
            CloseableResourceManager.active=false;
        }
        
        Closeable[] closeables=null;
        synchronized(CloseableResourceManager.RESOURCES)
        {
            //get resources
            closeables=CloseableResourceManager.RESOURCES.toArray(new Closeable[CloseableResourceManager.RESOURCES.size()]);
        }
        
        //get amount
        int amount=closeables.length;
        
        Closeable closeable=null;
        for(int index=0;index<amount;index++)
        {
            //get next element
            closeable=closeables[index];
            
            //close resource
            IOHelper.closeResource(closeable);
        }
    }
1185529
def close(self):
        '''
        
        '''
        if self.__arch is None:
            raise salt.exceptions.SaltException('Archive already closed')
        self._flush_content()
        self.__arch.close()
        self.__arch = None