Fix deletion of inactive threads