Fix hang on threadpool shutdown