Make terminate_threads() less likely to leave _threads containing invalid pointers.