Drupal - How to delete a vocabulary terms programmatically?

  $tids = \Drupal::entityQuery('taxonomy_term')
    ->condition('vid', 'mycustomvocab')
    ->execute();

  $controller = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
  $entities = $controller->loadMultiple($tids);
  $controller->delete($entities);

Just noting another approach to delete the taxonomy term individually, useful for some cases:

// Example to load and delete a taxonomy term
$tid = 12;
if ($term = \Drupal\taxonomy\Entity\Term::load($tid)) {
  // Delete the term itself
  $term->delete();
}