void (int flags, boolean restart, String @NotNull [] beforeRestart, int exitCode) { IJTracer tracer = TelemetryManager.getInstance().getTracer(new com.intellij.platform.diagnostic.telemetry.Scope("exitApp", null)); Span exitSpan = tracer.spanBuilder("application.exit").startSpan(); boolean force = BitUtil.isSet(flags, FORCE_EXIT); try (Scope scope = exitSpan.makeCurrent()) { if (!force && !confirmExitIfNeeded(BitUtil.isSet(flags, EXIT_CONFIRMED))) { return; } AppLifecycleListener lifecycleListener = getMessageBus().syncPublisher(AppLifecycleListener.TOPIC); lifecycleListener.appClosing(); if (!force && !canExit()) { return; } stopServicePreloading(); if (BitUtil.isSet(flags, SAVE)) { TraceUtil.runWithSpanThrows(tracer, "saveSettingsOnExit", (span) -> SaveAndSyncHandler.getInstance().saveSettingsUnderModalProgress(this)); } if (isInstantShutdownPossible()) { for (Frame frame : Frame.getFrames()) { frame.setVisible(false); } } try { lifecycleListener.appWillBeClosed(restart); } catch (Throwable t) { getLogger().error(t); } LifecycleUsageTriggerCollector.onIdeClose(restart); boolean success = true; ProjectManagerEx manager = ProjectManagerEx.getInstanceExIfCreated(); if (manager != null) { try { boolean projectsClosedSuccessfully = TraceUtil.computeWithSpanThrows(tracer, "disposeProjects", (span) -> { return manager.closeAndDisposeAllProjects(!force); }); if (!projectsClosedSuccessfully) { success = false; } } catch (Throwable e) { getLogger().error(e); } } try { scope.close(); exitSpan.end(); //noinspection TestOnlyProblems disposeContainer(); } catch (Throwable t) { getLogger().error(t); } //noinspection SpellCheckingInspection if (!success || isUnitTestMode() || Boolean.getBoolean("idea.test.guimode")) { //noinspection SpellCheckingInspection if (Boolean.getBoolean("idea.test.guimode")) { shutdown(); } return; } IdeaLogger.dropFrequentExceptionsCaches(); if (restart && Restarter.isSupported()) { try { Restarter.scheduleRestart(BitUtil.isSet(flags, ELEVATE), beforeRestart); } catch (Throwable t) { getLogger().error("Restart failed", t); StartupErrorReporter.showMessage(BootstrapBundle.message("restart.failed.title"), t); if (exitCode == 0) { exitCode = AppExitCodes.RESTART_FAILED; } } } System.exit(exitCode); } finally { exitSpan.end(); myExitInProgress = false; } }