code: public void closeFLACStream(byte[] md5Hash, StreamConfiguration streamConfig)
        throws IOException {
      //reset position in output stream to beginning.
      //re-write the updated stream info.
      streamLock.lock();
      try {
        if(!flacStreamIsOpen)
          throw new IllegalStateException("Error. Cannot close a non-opened stream");
        StreamConfiguration tempSC = new StreamConfiguration(streamConfig);
        tempSC.setMaxBlockSize(maxBlockSize);
        tempSC.setMinBlockSize(minBlockSize);
        EncodedElement streamInfo =  MetadataBlockStreamInfo.getStreamInfo(
            tempSC, minFrameSize, maxFrameSize, samplesInStream, md5Hash);
        if(out.canSeek()) {
          out.seek(streamHeaderPos);
          this.writeDataToOutput(streamInfo);
        }
        flacStreamIsOpen = false;
        out.close();
      } finally {
         streamLock.unlock();
      }
    }
docs: Close the current FLAC stream. Updates the stream header information.
  If called on a closed stream, operation is undefined. Do not do this.