Jet crash mars Air Force ceremony in Colorado

President Barack Obama, center, meets with Thunderbirds pilot Maj. Alex Turner at Peterson Air Force Base in Colorado Springs, Colo., Thursday after the officer from Chelmsford, Mass., safely ejected from his plane before it crashed in a pasture near the base. (Christian Murdock/The Gazette via AP, Pool)

COLORADO SPRINGS, Colo. (AP) — President Barack Obama implored the next generation of American military leaders Thursday not to give in to isolationism or pull back from U.S. leadership in the world, drawing a contrast with a foreign policy vision laid out by Donald Trump, then learned a U.S. Air Force Thunderbirds jet crashed moments after flying over the service academy graduation ceremony.

The F-16 was piloted by an officer from Chelmsford, Massachusetts, according to the Air Force. Maj. Alex Turner ejected safely from the plane, which went down in a rural area near Peterson Air Force Base. No one was injured and the cause of the crash is under investigation.

Obama used his final commencement address as president to reassure the military that it remains the world’s dominant fighting force, implicitly pushing back against critiques that its might has ebbed under his watch. Under searing sun and sweeping blue skies at the U.S. Air Force Academy, he told graduates they’d be called upon to strike a complicated balance between realism and idealism, withdrawal and overreach.

“We can’t be isolationists. It’s not possible in this globalized, interconnected world,” Obama said. “In these uncertain times, it’s tempting sometimes to try to pull back and wash our hands from conflicts that seem intractable, let other countries fend of themselves.”

Calling isolationism a “false comfort,” he added that history had shown how “oceans alone cannot protect us.”

For Obama, the speech was part of a tradition of addressing one of the military’s four service academies at graduation. His outdoor address ended with the dramatic flyover by the Thunderbirds demonstration team as cadets tossed their caps. Obama was still at the stadium at the time of the crash.

Turner later met with Obama at the Air Force base.

“The president thanked the pilot for his service to the country and expressed his relief that the pilot was not seriously injured,” said White House spokesman Josh Earnest. It was the second crash of the day involving one of the nation’s elite flying teams, as a U.S. Navy Blue Angels flier died in a crash near Nashville, Tennessee,during a practice flight earlier in the day.

In hi s speech to graduates, Obama didn’t mention Trump or other presidential candidates by name, but his target was clear. Trump, the presumptive Republican nominee, has called repeatedly for putting “America first” by rethinking U.S. alliances, spending less to ensure other countries’ security and enacting strict tariffs that Trump acknowledges could potentially lead to a trade war.

Obama’s rebuke of that philosophy came the same day the likely Democratic nominee, Hillary Clinton, sharply criticized Trump’s foreign policy. She delivered a speech in San Diego in which she assailed Trump as dangerous to U.S. national security and unqualified to be commander in chief.

Though Obama is waiting for the conclusion of the Democratic primary to start campaigning in earnest, he’s worked increasingly to undermine Trump’s appeal by attacking his policies. A day earlier, Obama visited a conservative stretch of Indiana on a self-described “myth-busting” mission to derail GOP arguments on the economy.

“When we panic, we don’t make good decisions,” Obama told the cadets and their families. He said the U.S. has to engage with the world but must also be wary of overextending itself, particularly with regard to military intervention.

“As we saw in Vietnam and the Iraq war, oftentimes the greatest damage to American credibility comes when we overreach, when we don’t think through the consequences of all of our actions,” Obama said.

In another clear nod to Trump, the president specifically mentioned the value of NATO, an alliance that Trump suggests is outdated.

Though Obama came into office pledging to end two wars and to keep the U.S. out of unnecessary entanglements, he’s repeatedly bumped into the reality of overseas messes that seem to have pulled the U.S. back in.

Nearing the end of his term, Obama is weighing whether to again increase the number of troops he’ll leave in Afghanistan. In Iraq, troop levels have crept back up, while special forces have been dispatched to Syria and Libya. Deep concerns about Russia and China have spurred calls for a more aggressive U.S. military posture in eastern Europe and Asia.

Of the 812 Air Force Academy graduates, 345 are going on to train as pilots, the Air Force said. Sixty will train to operate remotely piloted aircraft, such as drones, which Obama has made a central tool of U.S. counterterrorism efforts. About one-fourth of the Class of 2016 is female.

In the earlier crash, Marine Capt. Jeff Kuss died as his F/A-18 fighter went down just after takeoff, a U.S. official said. Kuss, a native of Durango, Colorado, managed to avoid causing any civilian casualties when his plane crashed in Smyrna, just outside Nashville. Kuss had previously served in Afghanistan.

Obama also delivered commencement addresses at Howard University and Rutgers University this year.