Improved the worker thread to prevent crashes of the worker on Windows.