private void clearScheduledQueries(HiveConf conf) {
    if (System.getenv(QTestUtil.QTEST_LEAVE_FILES) != null) {
      return;
    }
    Set<String> scheduledQueries = ScheduledQueryCreationRegistryHook.getSchedules();
    for (String name : scheduledQueries) {
      ScheduledQueryMaintenanceRequest request = new ScheduledQueryMaintenanceRequest();
      request.setType(ScheduledQueryMaintenanceRequestType.DROP);
      ScheduledQuery schq = new ScheduledQuery();
      schq.setScheduleKey(new ScheduledQueryKey(name, conf.getVar(ConfVars.HIVE_SCHEDULED_QUERIES_NAMESPACE)));
      request.setScheduledQuery(schq);
      try {
        Hive db = Hive.get(conf); // propagate new conf to meta store

        db.getMSC().scheduledQueryMaintenance(request);
        db.close(false);
      } catch (Exception e) {
        LOG.error("Can't remove scheduled query: " + name + " " + e.getMessage());
      }
    }
    scheduledQueries.clear();
  }
This handler does an aftertest cleanup; and deleters scheduled queries.
itests/util/src/main/java/org/apache/hadoop/hive/ql/scheduled/QTestScheduledQueryCleaner.java