import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class ExitFX extends Application {

    @Override
    public void start(Stage stage) {
        Button button = new Button("Exit");
        button.setOnAction(e -> Platform.exit());
        StackPane root = new StackPane(button);

        Scene scene = new Scene(root, 800, 600);
        stage.setTitle("Exit App");
        stage.setScene(scene);
        stage.show();
    }

    @Override
    public void stop() {
        Thread.getAllStackTraces().keySet().forEach(thread -> {
            if (!thread.isDaemon()) {
                System.out.println(thread);
            }
        });
    }

    public static void main(String[] args) {
        launch(args);
    }
}