Fix threading on Windows