docs: def close(self):
          """
          Flush the write buffers of the stream if applicable and
          close the object.
          """
          if self._writable and not self._closed:
              self._closed = True
              with self._seek_lock:
                  self._flush_raw_or_buffered()
              if self._seek:
                  with handle_os_exceptions():
                      self._close_writable()