At the end of 2015, retail giant Walmart announced it would close 269 stores across the globe, some 115 in the United States. This might seem puzzling. The company is the largest retailer in the country, and some 80 percent of U.S. shoppers visit the chain at least once a year. But thousands of locations and a huge customer base cannot save Walmart from the consequences of backward economic policy—like the minimum wage.

Among the stores closed were those in Oakland and Chinatown in Los Angeles. While the company’s decisions “took into account a number of factors,” Oakland and Los Angeles have something important in common: Both recently raised their minimum wage considerably higher than the national average.

Many have criticized Walmart for its wages, claiming that a firm bringing in some $482 billion in sales can afford to pay its workers more than the current prevailing wage. But while Walmart is large and profitable, it’s still subject to the laws of economics. Oakland, L.A. and other places are about to learn that increasing the minimum wage not only fails to increase wages for the poorest workers, but is also likely to backfire.

First, while the company’s revenues seem high, Walmart’s profit margin is far from fat: a mere 3 percent. The company has billions in expenses every year—so significant that in a 31-day month, all its sales in the first 30 days go toward paying expenses. Only on the 31st day does the company actually turn a profit, assuming nothing goes wrong during that month—like an unexpected jump in wages.

Just like any other firm, Walmart employs individuals who will earn the company revenue. After pay increases early this year, the average full-time Walmart employee will earn $13.38 per hour, well above the industry average of $10.29. With other benefits, including short-term disability and paid time off, the company’s actual cost per employee is significantly higher.

That Walmart pays an average of $13.38 an hour plus benefits means it expects the average employee to earn the company more than that amount. While a jump in pay of just a few dollars may seem trivial, for a company that employs 1.4 million domestic employees, it is positively massive. This is not to mention the additional costs associated with taxes paid for each employee. With such thin profit margins, Walmart cannot afford to ignore these costs.

As the cost of employing workers increases, Walmart has to decide whether its current workforce is worth the price. For example, if a worker’s hourly wage plus benefits is $30 per hour, but he or she generates only $25 in revenue, the company loses money for every hour the employee works. Under those circumstances, it would benefit the company and its shareholders to lay off workers. It has nothing to do with “corporate greed.” It’s business. Firms can’t operate at a loss.

Arbitrary wage increases, such as those dictated through minimum-wage laws, do nothing to make workers more productive. They just add costs. While proponents of the minimum wage intend for the burden to fall on “greedy” companies like Walmart, employees and consumers will feel the pain.

This is exactly what we’re observing in California. Instead of offering more people higher paying jobs, companies like Walmart will lay off hundreds of people who rely on the company for work.

Customers and communities lose out too. While Walmart caters to a variety of clientele, the company has been particularly helpful to some groups. More than 20 percent of Walmart customers live in rural areas. One in five customers receives food stamps or other assistance. Closing the stores means these consumers are out of luck. They have to find other—likely higher priced—alternatives, assuming such options are available at all.

Communities also lose out on the thousands of tax dollars Walmart pays to local and state governments every year, funding projects we all benefit from.

The closing of these stores should ring alarm bells for everyone concerned about economic well-being. When it comes to the minimum wage, everyone loses and it’s not Walmart’s fault. The responsibility lies with those who advocate and implement irresponsible economic policy.

[Update: An earlier version of this op-ed incorrectly stated Oakland’s minimum wage as $15 per hour. That mistake has been corrected in this version.]