code: public void close() throws IOException {   
      if (closed) {
        checkWriteThread();
        return;
      }
      try {
        buffer.close(); 
        // writeThread should exit after this
        // and close underlying stream
        try {
          writeThread.join();
        } catch (InterruptedException e) {
          throw new IOException(e);
        }
      } finally {
        checkWriteThread();
      }
    }
docs: Close the output stream. Joins the thread and
  closes the underlying output stream.