Distributed thread cleanup