How to remove entries with craft migration safeDown elegantly
As mentioned by Oli, I was able to use deleteElementById($entry-&gt;id). Note $id now refers to $elementId
/*
 * Find the matching entries to delete
 */

$entry = (new \craft\db\Query())
-&gt;select(&quot;elementId&quot;)
-&gt;from(&quot;content&quot;)
-&gt;where( &quot;title = &quot; . $title )
-&gt;all();

/*
 * Delete the entry
 */
foreach( $entry as $key =&gt; $value ) {

  // Hard delete.
  $success = Craft::$app-&gt;elements-&gt;deleteElementById( $value['elementId'], null, null , true );

}

Now entries deleted also deleted slugs that were created. But there was one problem: entries deleted previously before this migration code upgrade were still there. I found that these slugs were kept in the table element_sites and I manually deleted all the old slugs no longer being used. So far there has been no issue with this and the rest of the site functions apparently normally.