Refactor pool closing