docs: def _stop_process(p, name):
      """Stop process, by applying terminate and kill."""
      # Based on code in IPython.core.magics.script.ScriptMagics.shebang
      if p.poll() is not None:
          print("{} is already stopped.".format(name))
          return
      p.terminate()
      time.sleep(0.1)
      if p.poll() is not None:
          print("{} is terminated.".format(name))
          return
      p.kill()
      print("{} is killed.".format(name))