How to stop JavaFX clients in SBT (“fork” setting)

As a brief note, you need this “fork in run” setting in your sbt build.sbt file if you want JavaFX client/GUI applications to properly stop:

// see: https://stackoverflow.com/questions/5137460/sbt-stop-run-without-exiting
fork in run := true

Conversely, if you don’t use that setting and then you stop your JavaFX app that you started inside sbt, the app won’t stop properly and it will leave a Java process running, and at that point about all you can do is kill sbt and restart it, which gets annoying after a very short while. That setting causes sbt to create and run the JavaFX app in a new JVM. As noted in the code, I found that setting on SO.

“Treat every moment as your last.
It is not preparation for something else.”
 
~ Shunryu Suzuki