Usually, the JavaFX application closes once all of its windows (Stages) are closed.
You can close the application at any moment by calling javafx.application.Platform.exit().
If you don't want your application to automatically close, add the following code at the beginning of your program:
javafx.application.Platform.setImplicitExit(false);