Streamline thread shutdown handling and don't wait in the signal handler for all threads to shut down.

Also replaces the implicitly "__gshared" s_core.m_eventLoopRunning by a thread local s_eventLoopRunning. This sometimes caused threads to not exit when they should. See #419.