Panama’s decision to close a giant copper mine couldn’t come at a worse time for the market, and highlights the risk of investing big in some projects.

Just when the world faces a looming shortage of copper — a metal essential for the green revolution — Panama on Thursday said it will halt commercial operations at the Cobre Panamá operated by Canada’s First Quantum Minerals Ltd. It followed the breakdown of tax talks and is a rare move among Latin American countries.

The mine, which is one of the world’s newest and can produce about 300,000 tons a year of copper, cost at least US$10 billion to build.

  • Sign up to get breaking news email alerts sent directly to your inbox

The industry has long feared resource nationalism, where assets can be stripped from them in extreme cases. Investing can be a huge risk when billions of dollars must often be spent up to a decade before a mine turns a profit. The fear of losing assets or having to renegotiate terms with governments has led the sector to shy away from what are often perceived as the riskiest jurisdictions.

For example, mining heavyweight BHP Group for years only invested in what it saw as safe countries, while rich deposits remained undeveloped in the riskiest places.

In the short term, halting output at Cobre Panama will add to already tight supplies. In recent weeks both Glencore Plc and Anglo American Plc have lowered copper production goals for the coming years. But the impact on companies’ willingness to build more mines could be more significant, according to BMO Capital Markets.

“Perhaps more important however is the precedent this might set for government action, which would naturally make companies more cautious to invest (particularly in non-mining jurisdictions),” BMO analyst Colin Hamilton said.

Warnings that the world needs more copper keep coming. Glencore Chief Executive Officer Gary Nagle earlier this month said there’s a cumulative gap between projected demand and supply of 50 million tons between 2022 and 2030. That compares with current world copper demand of about 25 million tons a year.

Copper miners and analysts have forecast growing deficits starting in the mid-2020s, driven by rising demand for the metal in wind and solar farms, high voltage cables and electric vehicles.