public static void setQuitHandler( Consumer<QuitResponse> quitHandler ) {
		if( !isSupported( Action.APP_QUIT_HANDLER ) )
			return;

		String handlerClassName;
		if( SystemInfo.isJava_9_orLater )
			handlerClassName = "java.awt.desktop.QuitHandler";
		else if( SystemInfo.isMacOS )
			handlerClassName = "com.apple.eawt.QuitHandler";
		else
			return;

		try {
			Object desktopOrApplication = getDesktopOrApplication();
			Class<?> handlerClass = Class.forName( handlerClassName );

			Method m = desktopOrApplication.getClass().getMethod( "setQuitHandler", handlerClass );
			m.invoke( desktopOrApplication, Proxy.newProxyInstance( FlatDesktop.class.getClassLoader(),
				new Class[] { handlerClass },
				(proxy, method, args) -> {
					Object response = args[1];
					String responseClass = SystemInfo.isJava_9_orLater
						? "java.awt.desktop.QuitResponse"
						: "com.apple.eawt.QuitResponse";
					quitHandler.accept( new QuitResponse() {
						@Override
						public void performQuit() {
							try {
								Class.forName( responseClass ).getMethod( "performQuit" ).invoke( response );
							} catch( Exception ex ) {
								LoggingFacade.INSTANCE.logSevere( null, ex );
							}
						}

						@Override
						public void cancelQuit() {
							try {
								Class.forName( responseClass ).getMethod( "cancelQuit" ).invoke( response );
							} catch( Exception ex ) {
								LoggingFacade.INSTANCE.logSevere( null, ex );
							}
						}

					} );
					return null;
				} ) );
		} catch( Exception ex ) {
			LoggingFacade.INSTANCE.logSevere( null, ex );
		}
	}
Sets a handler which is invoked when the application should quit.
The handler must invoke either {@link QuitResponse#performQuit} or
{@link QuitResponse#cancelQuit}.
<p>
Useful for macOS to get notified when user clicks menu item "MyApp &gt; Quit".
<p>
Uses:
<ul>
<li>Java 8 on macOS: com.apple.eawt.Application.getApplication().setQuitHandler(com.apple.eawt.QuitHandler)
<li>Java 9+: java.awt.Desktop.getDesktop().setQuitHandler(java.awt.desktop.QuitHandler)
</ul>
flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/FlatDesktop.java