code: def close(self):
          
          try:
              self.p.stdin.write(bytes("X\n","utf-8"))
              self.p.stdin.flush()
          except IOError:
              self.report("could not send exit command")
          self.p.wait() # wait until the process is closed
          try:
              os.remove(self.tmpfile) # clean up the temporary file
          except FileNotFoundError:
              pass
docs: Tell the process to exit