Accidentally noticed that destroying GEM window when processing messages from gemkeyboard will crash PD (same thing happens with gemmouse).
This patch illustrates the bug and the workaround: pressing ESC in GEM window will close it, crashing PD if you check the "crash on escape" toggle.
Vasily