Fix infrequent hangs in test-runner. (#16793)