Fix crash after Ctrl-C on Windows

This fixes a crash in GetMainThreadId() where it removes invalids threads
from a vector. Surprisingly this didn't give a runtime error in VS 2013
(caught it with VS 2010).