This was uncovered when testing the latest lanai repo, up to this commit:
https://github.com/openjdk/lanai/commit/478286d5470bf7bb933f87d5842c42eb16252dd8
and including the fixes for JDK-8262750, JDK-8262729, and JDK-8262496.
I reproduced this as follows:
1. Enable the discrete graphics card (so there would be no graphics card switch, although it doesn't matter to this bug)
2. Run NetBeans without metal API validation
3. Plug in external monitor
4. Unplug external monitor
5. Repeat steps 3-4 until it crashes