“THE horse may be out of the proverbial barn.” So wrote Ben Bernanke, a former chairman of the Federal Reserve, in early 2016, arguing that capital controls might be powerless to save China from a run on its currency. He was far from alone at the time. As cash rushed out of the country, analysts debated whether the yuan would collapse, and some hedge funds bet that day was coming fast. But two years on, the horse is back in the barn: the government’s defence of the yuan has succeeded, in part through tighter capital controls.

The latest evidence was an 11th consecutive monthly increase in foreign-exchange reserves in December. During that time China’s stockpile of official reserves, the world’s biggest, climbed by $142bn, reaching $3.14trn, roughly double the cushion usually regarded as needed to ensure financial stability. Another sign of China’s success is the yuan itself. At the start of 2017 the consensus of forecasters was that the currency would continue to weaken; it finished the year up by 6% against the dollar.

Investors and analysts were not wrong in viewing Chinese capital controls as porous. Enterprising types had—and have—umpteen ways to sneak money out, from overpaying for imports to smuggling cash across the border in luggage. But there is a wide spectrum between a fully open and fully closed capital account, and China has showed over the past year that it can tilt towards closure, at least for a time.

Its measures were directed at actors big and small. Under more scrutiny from regulators, China’s overseas acquisitions fell by more than a third, to $140bn last year. Individuals were still permitted to convert up to $50,000 a year, but they faced heavier disclosure burdens. The government is in no hurry to relax these controls: a new, lower ceiling on withdrawals from ATMs abroad went into effect on January 1st.

Also crucial to China’s defence of the yuan was an economic rebound. Housing prices soared and industrial firms’ profits rose by 20% last year on the back of higher commodity prices. Here, Mr Bernanke can claim some vindication: in looking at China’s options in 2016, he had suggested that a fiscal boost would support growth and so help keep cash at home. An unconventional policy mix—investment in low-income housing and closure of excess industrial capacity—did the trick.