Wait for all children to terminate