Clean backport of this crash-on-exit fix to the `jfx23` stabilization branch.
------------- Commit messages: - Backport 81f11c4a39eb505d17c57a49c5e084f75a169856 Changes: https://git.openjdk.org/jfx/pull/1511/files Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1511&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8335630 Stats: 157 lines in 4 files changed: 130 ins; 0 del; 27 mod Patch: https://git.openjdk.org/jfx/pull/1511.diff Fetch: git fetch https://git.openjdk.org/jfx.git pull/1511/head:pull/1511 PR: https://git.openjdk.org/jfx/pull/1511