如何停止循环中的xml导入?

i try to import my xml file with 146 356 name. But when i start import it puts in database about 400 000 name. Script doesn't stop and repeat a loop several times.

我的xml:

<licenses_list>
    <licenses>
        <name>My first name</name>
    </licenses> 
</licenses_list>

脚本

 if (file_exists('data.xml')) {
    $reader->open('data');
    $start = microtime(true);
    while ($reader->read() ) {

        if ($reader->nodeType == XMLReader::ELEMENT) {
            if ($reader->localName == 'licenses') {
               $legal_uuid = Uuid::uuid4();
                $node = simplexml_import_dom($doc->importNode($reader->expand(), true));
                $name = (string) $node->name;                try {
                    echo $inn;
                    $sth->execute([
                        ':uuid' => $legal_uuid,
                        ':name' => $name                       
                    ]);
                } catch (PDOException $e) {
                    die($e->getMessage());
                }
            }
        }
    }
    $reader->close();
} else {
    exit('cannot open the file');
}

It doesn't stop at </licenses_list> ? How to solve it?
P.S. and script works about 3 hours to parse 146 000 names