Fix "thread apply all" with exited threads