Fix Cygwin crashing on quit

And fixed, ready to merge!