selftest: improve logic in cleanup_child() with early return