In Reading mode, will close the underlying ogg
file and free its resources.
In Writing mode, will write out the Info, Comments
and Setup objects, and then the audio data.
965535
public void close() throws IOException {
        if(r != null) {
            r = null;
            ogg.close();
            ogg = null;
        }
        if(w != null) {
            w.bufferPacket(firstPacket.write(), true);
            w.bufferPacket(tags.write(), false);
            // TODO Write the others
            //w.bufferPacket(setup.write(), true);

            long lastGranule = 0;
            for(FlacAudioFrame fa : writtenAudio) {
                // Update the granule position as we go
                // TODO Track this
//              if(fa.getGranulePosition() >= 0 &&
//                 lastGranule != fa.getGranulePosition()) {
//                 w.flush();
//                 lastGranule = fa.getGranulePosition();
//                 w.setGranulePosition(lastGranule);
//              }

                // Write the data, flushing if needed
                w.bufferPacket(new OggPacket(fa.getData()));
                if(w.getSizePendingFlush() > 16384) {
                    w.flush();
                }
            }

            w.close();
            w = null;
            ogg.close();
            ogg = null;
        }
    }
1078922
def close(self):
        
        self.sync()
        self.sync = self.create = self.delete = self._closed
        self._write_to_file = self._read_to_file = self._closed
        self._key_to_filename = self._filename_to_key = self._closed
        self.__getitem__ = self.__setitem__ = self.__delitem__ = self._closed
        self.__iter__ = self.__len__ = self.__contains__ = self._closed
849132
public void freeResources() throws IOException {
        if(reader != null) {
            reader.close();
        }
        if(servletInputStream != null) {
            servletInputStream.close();
        }
    }
133675
@Override
  public void close() {
    unmap();
    writer.close();
    readers.forEach(reader -> reader.close());
    open = false;
  }
848652
def close(self: Any) -> None:
        
        if self._file_obj is not None:
            self._file_obj.close()
        self._file_obj = None
977713
def close(self):
        
        # Check if any of the files have already been closed
        shp_open = self.shp and not (hasattr(self.shp, 'closed') and self.shp.closed)
        shx_open = self.shx and not (hasattr(self.shx, 'closed') and self.shx.closed)
        dbf_open = self.dbf and not (hasattr(self.dbf, 'closed') and self.dbf.closed)
            
        # Balance if already not balanced
        if self.shp and shp_open and self.dbf and dbf_open:
            if self.autoBalance:
                self.balance()
            if self.recNum != self.shpNum:
                raise ShapefileException("When saving both the dbf and shp file, "
                                         "the number of records (%s) must correspond "
                                         "with the number of shapes (%s)" % (self.recNum, self.shpNum))
        # Fill in the blank headers
        if self.shp and shp_open:
            self.__shapefileHeader(self.shp, headerType='shp')
        if self.shx and shx_open:
            self.__shapefileHeader(self.shx, headerType='shx')

        # Update the dbf header with final length etc
        if self.dbf and dbf_open:
            self.__dbfHeader()

        # Close files, if target is a filepath
        if self.target:
            for attribute in (self.shp, self.shx, self.dbf):
                if hasattr(attribute, 'close'):
                    try:
                        attribute.close()
                    except IOError:
                        pass
757767
public void close() throws IOException {

		//PrintWriter.close does not throw exceptions. Thus, the call does not need
		//be inside a try-catch block.
		if (this.printWriter != null) {
			this.printWriter.close();
		}

		if (this.gzipOutputStream != null) {
			this.gzipOutputStream.close();
		}
	}
1176787
void close() {
    acquireExclusiveLock();
    try {

      if (buffer != null) {
        if (dirty)
          buffer.force();

        if (sunClass != null) {
          // USE SUN JVM SPECIAL METHOD TO FREE RESOURCES
          try {
            final Method m = sunClass.getMethod("cleaner");
            final Object cleaner = m.invoke(buffer);
            cleaner.getClass().getMethod("clean").invoke(cleaner);
          } catch (Exception e) {
            OLogManager.instance().error(this, "Error on calling Sun's MMap buffer clean", e);
          }
        }

        buffer = null;
      }
      counter = 0;
      file = null;

    } finally {
      releaseExclusiveLock();
    }
  }
420026
def close(self):
        
        self.out_stream.close()
        # If we're asked to write in place, substitute the named
        # temporary file for the current file
        if self.in_place:
            shutil.move(self.temp_file.name, self.out)
627841
public void close() {
        // getting a read lock will ensure all writes have finished
        // if we are really closing assume that we don't care about reads
        readLock.lock();
        try {
            if (container != null) {
                try {
                    container.close();
                    container = null;
                    log.info("Closed container");
                } catch (XmlException e) {
                    log.warn("close failed: " + e.getMessage(), e);
                }
            }

            if (manager != null) {
                try {
                    manager.close();
                    manager = null;
                    log.info("Closed manager");
                } catch (XmlException e) {
                    log.warn("close failed: " + e.getMessage(), e);
                }
            }
        } finally {
            readLock.unlock();
        }
    }
798194
public void destroy() {
        if (inputStream != null)
        {
            try
            {
                inputStream.close();
            } catch (Throwable t)
            {
                LOG.warn("Error closing input stream", t);
            }
            inputStream = null;
        }
        if (outputStream != null)
        {
            try
            {
                outputStream.close();
            } catch (Throwable t)
            {
                LOG.warn("Error closing output stream", t);
            }
            outputStream = null;
        }
        if (errorStream != null)
        {
            try
            {
                errorStream.close();
            } catch (Throwable t)
            {
                LOG.warn("Error closing error stream", t);
            }
            errorStream = null;
        }
        if (ffmpeg != null)
        {
            ffmpeg.destroy();
            ffmpeg = null;
        }
        if (ffmpegKiller != null)
        {
            Runtime runtime = Runtime.getRuntime();
            runtime.removeShutdownHook(ffmpegKiller);
            ffmpegKiller = null;
        }
    }
287406
def close(self):
        """"""
        if not self.is_open:
            return
        if self.writable:
            check_call(_LIB.MXRecordIOWriterFree(self.handle))
        else:
            check_call(_LIB.MXRecordIOReaderFree(self.handle))
        self.is_open = False
        self.pid = None
715844
@Override
    public synchronized void close() throws IOException {
        if (_mode == Mode.CLOSED) {
            return;
        }
        
        _mode = Mode.CLOSED;
        
        try {
            // THE CALLS ORDERED. 
            _compactor.shutdown();   // shutdown compactor
            
            /* Call syncInternal() to force update changes accumulated in
             * the last update batch and those generated by data compaction.
             */
            syncInternal();          // consume compaction batches generated during shutdown
            
            /* Submit the current segment index buffer before closing _segmentManager
             * so that the last writer segment index buffer can be flushed to disk
             * when _segmentManager.close() is being invoked.
             */
            submitSegmentIndexBuffer();
            
            _compactor.clear();      // cleanup compactor internal state
            _addressArray.close();   // close address array
            _segmentManager.close(); // close segment manager
        } catch(Exception e) {
            _log.error("Failed to close", e);
            throw (e instanceof IOException) ? (IOException)e : new IOException(e);
        } finally {
            _mode = Mode.CLOSED;
            _log.info("mode=" + _mode);
        }
    }
1121973
public void close() throws IOException {

        writeStream.close();

        if (!writeFile.delete()) {
            throw new IOException(
                RB.singleton.getString(
                    RB.WORKFILE_DELETE_FAIL, writeFile.getAbsolutePath()));
        }
    }
325506
public function close() {

            if (is_resource($this->stream)) {

                fclose($this->stream);

                $this->isReadable = false;
                $this->isWritable = false;
                $this->isSeekable = false;
                $this->meta       = array();

            }

        }
356363
public void close() throws IOException {
        if(r != null) {
            r = null;
            ogg.close();
            ogg = null;
        }
        if(w != null) {
            w.bufferPacket(info.write(), true);
            w.bufferPacket(tags.write(), false);

            long lastGranule = 0;
            for(SpeexAudioData vd : writtenPackets) {
                // Update the granule position as we go
                if(vd.getGranulePosition() >= 0 &&
                        lastGranule != vd.getGranulePosition()) {
                    w.flush();
                    lastGranule = vd.getGranulePosition();
                    w.setGranulePosition(lastGranule);
                }

                // Write the data, flushing if needed
                w.bufferPacket(vd.write());
                if(w.getSizePendingFlush() > 16384) {
                    w.flush();
                }
            }

            w.close();
            w = null;
            ogg.close();
            ogg = null;
        }
    }
369197
def close(self):
        
        logging.debug("closing interface")
        self.closed = True
        self.read_sem.release()
        self.thread.join()
        usb.util.dispose_resources(self.dev)