In Europe for nearly a century, General Motors has weathered a World War, a Cold War, the Great Depression and the bankruptcy of its parent company.

But Brexit was the final straw.

GM announced Monday it will sell Opel and Vauxhall, two European brands it has owned since the 1920s, to French automaker PSA Group. CEO Mary Barra and other executives pointed to Brexit and the "changing geopolitical landscape" as a major part of the reason for the sale.

To be clear, Brexit wasn't the only problem facing GM in Europe.

Over the past 17 years, GM has lost $22.4 billion in Europe. But those losses have been narrowing, and the company says it would have been profitable in Europe last year for the first time since 1999 -- without Brexit.

Related: GM selling its European business in $2.3 billion deal

The risks posed by political uncertainty in Europe outweighed the potential to turn a steady profit in Europe, GM President Dan Ammann said on a call with investors early Monday.

"We expect geopolitical events will continue to impact commerce in the region, as we're experiencing real time with the impact of Brexit," he said.

So far most of the impact on car sales has been due to the devaluation of the British pound versus the euro since the Brexit vote. But concerns are mounting about the increased cost of production once the U.K. leaves the EU.

Automakers that build and sell cars in Europe depend on free trade for car parts and cars across Europe. Just as President Trump's vow to place a border tax on Mexican goods has worried U.S. automakers who all have plants on both sides of the border, those with European operations are worried how they will deal with the U.K.'s departure from the EU. And it may not end with the U.K. French presidential candidate Marine Le Pen, who is leading in many polls, has vowed to call for a vote on whether France should also exit the EU if she is elected, which some have suggested could lead to the end of the EU.

GM executives did not mention Le Pen or the future of the EU on Monday. But Ammann did say, "We see risks in these markets that could outweigh these opportunities, making this the right time to divest the Opel-Vauxhall business."

Related: How many of GM's 38,000 jobs in Europe will survive

GM had already pulled its Chevrolet brand from Europe three years ago in an effort to stem losses. And it actually had reached a deal once before to sell Opel in 2009 as it prepared to file for bankruptcy. But it eventually pulled out of that deal with the hope it could turn around its prospects in Europe. But back then there was no doubt about the EU.

There are other issues as well, including concerns about increased regulatory costs in Europe, especially in the wake of the Volkswagen diesel emissions scandal. Diesel cars, which are a niche product in the United States, are a major portion of the car market in Europe.

And GM's relatively weak position in Europe shows no signs of turning around. Opel and Vauxhall have only about 6% of the market, down from 9% in 2000.

"It is a big market to walk away from," said Rebecca Lindland, executive analyst for Kelley Blue Book. "But Opel/Vauxhall was a money-losing puzzle no one at GM could solve for decades, and outside forces such as Brexit did not help the situation"