Ensure foreground context is current on the main thread

Background must be non-current, otherwise it will raise error 170 (resource is in use) on the next MakeCurrent() call.

Fixes issue #2474