ON A sunny November day, the RiverWalk along the Detroit river is deserted. The once-bright flowerbeds are overgrown with weeds, the café closed and the merry-go-round at a standstill. Detroit, once the motor of America’s car industry, feels emptied out, and so it is. Its population has shrunk to 689,000, two-fifths of the number who lived there in 1960.

The biggest exodus occurred in the past decade, when both the city and two of the three biggest car companies, General Motors and Chrysler, were heading for the financial abyss. The federal government bailed out the carmakers to the tune of $80 billion, but refused to help the city. Detroit, $18 billion in debt, therefore filed for bankruptcy in July last year, the biggest city ever to do so. Sixteen months later it is about to emerge from Chapter 9, the section of the bankruptcy code that deals with municipalities. On November 7th Steven Rhodes, a bankruptcy judge, approved the city’s plan to slash $7 billion of unsecured liabilities from its debt. This, it is hoped, will put its finances on a sound footing.

Detroit has a long history of mismanagement, epitomised by Kwame Kilpatrick, who was mayor from 2002 to 2008 and is now in prison. Yet its bankruptcy has been handled with impressive efficiency by Kevyn Orr, the lawyer appointed by Rick Snyder, the governor of Michigan, and by Judge Rhodes, who presided over the bankruptcy trial and appointed an able mediator, Gerald Rosen, another judge.

The agreement will cause some pain to both pensioners and bondholders. The pensions of public employees will be cut by 4.5% and the cost-of-living adjustments will go, except for police officers and firefighters. Health-care benefits will be trimmed for both groups. Some bondholders will receive as much as 75 cents on the dollar, but others, such as Syncora, a bond insurer, and Financial Guaranty Insurance, another bond insurer with a claim of $1 billion, will have to take huge losses.

The most original of the many settlements with Detroit’s 100 creditors was the “grand bargain” masterminded by Judge Rosen. He talked some of America’s biggest foundations and the state of Michigan into rescuing the first-rate collection of the Detroit Institute of Arts (DIA) by pledging $816m to protect it from the city’s creditors. The funds raised will help to pay public workers’ pensions over the next ten years, and the ownership of the museum has been transferred from the municipality to an independent charitable trust.

Will the city repay the foundations’ optimism? First of all, says Bettie Buss, an expert on Detroit, the city must show it can look after its citizens. Roads are in disrepair; more than one-third of street lights don’t work; public schools are a shambles; the municipal government’s computer system is antiquated; thousands of households have no water, and 84,000 building plots are derelict or vacant. Moreover, the city is unsafe nearly everywhere. According to the FBI’s statistics for 2013, Detroit has the highest rates of murder and violent crime among America’s big cities.

The adjustment plan sets aside $1.7 billion for investment in infrastructure and basic services in the next ten years. It is a vast sum for a city that has trimmed investments to the bone in recent years, but it will soon run out. Unless Detroit smartens itself up, though, no one will lend to it.

Martha Kopacz, a Boston-based consultant hired by Judge Rhodes, thinks the biggest risk is a loss of focus when the present group of leaders leaves. Mike Duggan, the mayor, gets high marks, but he may be in office for only three more years. Ms Kopacz wanted a stronger oversight commission, appointed by Governor Snyder, which could take control if things went bad again. As it is, a nine-member financial-review commission will approve city budgets and assess bigger contracts and labour agreements, but its ability to intervene is limited.