Avoid deadlock when waiting for children to exit.