private synchronized void stopApplication() {
        if (openfired != null) {
            try {
                // attempt to perform a graceful shutdown by sending
                // an "exit" command to the process (via stdin)
                try (Writer out = new OutputStreamWriter(
                        new BufferedOutputStream(openfired.getOutputStream()))) {
                    out.write("exit\n");
                }
                final Thread waiting = Thread.currentThread();
                Thread waiter = new Thread(() -> {
                    try {
                        // wait for the openfire server to stop
                        openfired.waitFor();
                        waiting.interrupt();
                    }
                    catch (InterruptedException ie) { /* ignore */ }
                });
                waiter.start();
                try {
                    // wait for a maximum of ten seconds
                    Thread.sleep(10000);
                    waiter.interrupt();
                    openfired.destroy();
                }
                catch (InterruptedException ie) { /* ignore */ }
                cardLayout.show(cardPanel, "main");
            }
            catch (Exception e) {
                e.printStackTrace();
            }
        }

        openfired = null;
    }
Creates a new GUI launcher instance.
@param args The command line arguments
@throws AWTException if AWT cannot be initialised
starter/src/main/java/org/jivesoftware/openfire/launcher/Launcher.java