Setup proper return type for thread callback

Also make sure to import HANDLE for Windows.