docs: def stop_reactor_on_state_machine_finish(state_machine):
      """ Wait for a state machine to be finished and stops the reactor
  
      :param state_machine: the state machine to synchronize with
      """
      wait_for_state_machine_finished(state_machine)
      from twisted.internet import reactor
      if reactor.running:
          plugins.run_hook("pre_destruction")
          reactor.callFromThread(reactor.stop)