thread pool cleanup logic