@Override
  public void stop() {
    synchronized (getLock()) {
      if (myOriginal.isRunning()) {
        myOriginalStarted = true;
        myOriginal.stop();
      }
      myStartupAlarm.cancel(false);

      // needed only for correct assertion of !progress.isRunning() in ApplicationImpl.runProcessWithProgressSynchronously
      final Semaphore semaphore = new Semaphore();
      semaphore.down();

      SwingUtilities.invokeLater(
        () -> {
          if (!myOriginalStarted && myOriginal instanceof Disposable) {
            // dispose original because start & stop were not called so original progress might not have released its resources
            Disposer.dispose((Disposable)myOriginal);
          }

          semaphore.waitFor();
          if (myDialog != null){
            myDialog.close(DialogWrapper.OK_EXIT_CODE);
            myDialog = null;
          }
        }
      );

      try {
        super.stop(); // should be last to not leaveModal before closing the dialog
      }
      finally {
        semaphore.up();
      }
    }
  }
@Override
  public void stop()