Clean up error handling in threadengine_win32