Fixed deadlock on exit, using size_t for x64 complience