code: def _close_stdout_stderr_streams(self):
          
  
          # we don't have tee_file's in headless mode
          if self._stdout_tee.tee_file is not None:
              self._stdout_tee.tee_file.close()
          if self._stderr_tee.tee_file is not None:
              self._stderr_tee.tee_file.close()
  
          # TODO(adrian): we should close these even in headless mode
          # but in python 2 the read thread doesn't stop on its own
          # for some reason
          self._stdout_tee.close_join()
          self._stderr_tee.close_join()
  
          if self._cloud:
              # not set in dry run mode
              self._stdout_stream.close()
              self._stderr_stream.close()
  
          self._output_log.f.close()
          self._output_log = None
docs: Close output-capturing stuff. This also flushes anything left in
          the buffers.