Fixes issue on Wayland due to drop order, since TLS is being dropped after the event loop, while it shouldn't. In particular it fixes the crash in the window_run_return example.
Fixes #776.