Fix deadlock in ThreadPool::Join.

Refs #4986
Merge branch 'feature/threadpool-join-4986' into next

Fixes #4986