This solution seems to work perfectly for me. Since the foreign code
is allowed to run uninterrupted, the GPU switch happens, and since the
GUI actions stay on the main thread, the program's window responds to
keyboard and mouse input correctly.
If that's correct, then I think you have found a bug in the GHC runtime: my understanding is that the timers should be disabled while foreign code is running, specifically to avoid confusing code that has no clue that there is another runtime involved.
--