Bad ideas tend to naturally follow from bad investments. The latest example: bailing out people who overpaid for taxi medallions, the city licence that allows drivers to pick up riders who hail them on New York streets. This all came about because Uber and Lyft have been taking market share at the expense of cabs, sending medallion values into a tailspin.

Just like many homebuyers of the 2000s, medallion owners find themselves underwater on the purchase price, deep in debt and looking for a rescue. They should take a page from those same homeowners and just walk away.

Medallion owners can take full advantage of the bankruptcy system to discharge their debts, leaving those bad investments behind. It is painful, but the so-called sunk-cost fallacy teaches us that we should not throw good money after bad. Asking federal or municipal taxpayers to rescue them from their own folly creates a moral hazard of the highest order. The issue affects a small number of taxi owners; it does not present a broader systemic risk of any kind. The entire matter is best handled through the bankruptcy courts. But no, some of New York’s political leaders are intent on pushing through with a bailout anyway.

A brief reminder of how we got here: the New York City Taxi and Limousine Commission (TLC) was created in 1971 in response to corrupt police oversight of the taxi industry. But it was not long before the TLC itself was subject to regulatory capture, and stopped advocating on behalf of taxi riders and city residents. Instead, it became a front for medallion owners, intentionally limiting the number of taxi cabs available.

Why? The medallions themselves had become so valuable. The TLC behaved as if its charge was to maximise the wealth of taxi owners, even if that was to the detriment of taxi riders.

This fundamentally altered the properties of the medallions. They were supposed to be a licence to drive a cab, but instead became an investment asset. From 1975 to 2013, medallions generated returns of 2,706%, outpacing the Dow Jones industrial average’s gain of 1,675% or gold’s 846% increase. By 2013, the value of all New York taxi medallions was $16.6bn.

For almost four decades, taxi medallions were, as one headline put it, “the best investment in America”.

That incredible wealth distorted the TLC’s mandate. Its mission was to oversee an industry that is an essential part of New York’s urban transport network. And its constituency was supposed to include passengers, drivers, vehicle owners, taxpayers and local businesses. The TLC lost sight of that, working instead to protect the interests of the medallion owners by limiting the supply — in short, by acting like a monopolist.

Consider the city’s growth in population and medallions. In 1937, there were about 16,900 taxis licensed to accept roadside passenger hails. In the ensuing 82 years, the city’s population grew by more than 1-million people. Add in commuters and tourists, and on any given day the population of Manhattan can double. And even though the TLC has allowed 1,800 new medallions to be issued since 1996 there still are fewer medallions today than in 1937.

Is it any surprise that market forces eventually broke the monopoly?

Let us shift focus a bit and ask, What did anyone who was not a medallion owner get out of the old arrangement? Little that was good, and cab service was widely deemed unsatisfactory.

The app-based ride hailing services simply took advantage of the opportunity presented by this market distortion, rushing in to meet all of the pent-up demand. The result: by 2017, Uber was averaging 289,000 daily trips vs 277,000 for Yellow Cabs, and this year Lyft is on the cusp of passing Yellow Cabs as well. Together, Uber and Lyft captured 65% more rides in 2017 than cabs, and that figure surely is higher today.

Soon after Uber broke the supply limitation in New York, medallion prices began to plummet. Bloomberg BusinessWeek reported that prices peaked in 2013 at $1.3m per medallion. By 2015, prices had fallen more than 40%; by 2016, the lowest reported price was $250,000. Some transactions went for just 8% of the peak value. It is not just New York — other cities, such as Chicago, have seen similar declines.

You might not like it, but this is how markets tend to work, and there are almost always winners and losers.

Instead of asking the city to take over the loans from private individuals or companies that borrowed to buy medallions, this should be the work of private investment funds. They have the capital and expertise to acquire these damaged assets and make something out of them. The alternative — a city bailout — would cost local taxpayers about $1bn, socialising the losses of 6,000 medallion owners.

Some have claimed that predatory lenders snookered medallion buyers with abusive financing. If that is the case, the courts are the proper venue for resolving those complaints. But bailing out bad investments in medallions would set a terrible precedent. It is not the role of the city to ensure do-overs of foolish business decisions.

• Ritholtz is a Bloomberg Opinion columnist.