code: def _finish(self):
          
          if self._process.returncode is None:
              self._process.stdin.flush()
              self._process.stdin.close()
              self._process.wait()
              self.closed = True
docs: Closes and waits for subprocess to exit.