If there was one family in Afghanistan who incarnated the hopes, illusions and failures of the last two decades there, it was the Ghanis.

Ashraf, the father, was the country’s last president. A trained anthropologist, he believed in books, and the power of the ideas within them to move the world. His wife, Rula, a student in Paris in 1968, said she believed in women. Mariam, their daughter, became a filmmaker — she believed in Art. Their son, Tarek, believed in his father. His two-decade career in American academia and philanthropy is an echo of Ashraf’s own cloudless trajectory through blue-chip universities, the World Bank and think tanks. It was a tribute.

For half a century, Afghanistan was simultaneously obscure and at the centre of world events. It had swallowed the fading comet tail of the USSR and absorbed the late afternoon light of American Empire. It had been a hideaway for renegades and a bazaar of ideologies. From Hippie free love to political Islamism, from Marxist-Leninism to market democracy — all had been hawked and bartered over in Afghanistan.

Whether it was itself a “real” country at all, or simply a vast outdoor laboratory worked by imperial meddlers and narco-criminals was hard to say. But every force and idea that acted on Afghanistan acted on the Ghanis too. They were both the victims of events and the instigators of them. They had been exiles, then leaders; they had been scattered across the globe and enthroned in Kabul. The family was Pashtun, and prominent, with a history of political influence. The Ghanis first left in 1977, as the communists began their takeover.

Ashraf Ghani fled again this week. Mariam posted about it — “I’m pretty burned out” — on Instagram from her home in New York. Tarek and Rula have so far remained silent. This time it was widely reported that Ashraf had attempted to upholster four cars and a helicopter with millions of stolen dollars. This was surely — hopefully — untrue, and not because the source was a Russian news agency.

By Afghan standards the Ghanis were not that corrupt. It was for other politicians to mainline America’s billions into lavish compounds, or to be apprehended in Dubai’s airport with $52 million in cash. Ashraf did not believe in money. He believed in books.

When he became President, in 2014, after a fraught and nervous election, he indulged his obsession. Like all Afghan presidents, Ghani moved to the Arg — a labyrinth of palaces within a 19th-century fortress in central Kabul. But unlike his predecessor, he immediately set about restoring the ruined royal library, with all its decaying antique volumes. His personal library was his most valuable asset, according to a New Yorker profile. He owned seven thousand books. Every day he woke up before the sun rose and read them under his favourite chinar tree. He would have taken his volumes, not cash, when he fled on Sunday, wouldn’t he?

Ghani didn’t just read books — he wrote them. With his collaborator, the British human rights lawyer Claire Lockhart, he published Fixing Failed States: A Framework for Rebuilding a Fractured World (2008). “Novel strategies” were needed, they argued, to stabilise failed states that were contaminating “our fully globalised world” with anarchy.

By the end of the first decade of the 21st century, these chaotic zones were spreading. Ghani believed he had the ideas — a “sovereignty index” to be annually published by the UN, and a “citizens-based approach” to state-building — that could mop away the disorder. Fixing Failed States offered, according to a small review in Foreign Affairs, “a surprisingly hopeful vision”.

The vision was delivered as a TED talk in 2007. Ghani’s manner is cerebral, candid, impish, shrilly excitable — theory excites him. His voice is as squeaky as an old floorboard being stepped on. The TED stage suited a pedagogue like Ghani. It was not so different from the lecture halls and seminar rooms of John Hopkins, where he’d spent the 1980s teaching. He never looks uncomfortable.

America was comfortable enough for the Ghanis. It was their main chance, as it was for other exiled Afghans. It gave Ashraf, Rula and Tarek the opportunity to collect the academic prizes that are today’s proof of intelligence and moral worth. It allowed Mariam to transform herself from the child of exiles to an artist; not merely an artist working in “installation, performance, photography, text and video”, but, according to the Guggenheim Foundation, an “activist, archivist, writer and lecturer”.

A 2015 New York Times profile found Mariam in her loft apartment in Clinton Hill, worrying about being “a Brooklyn cliche”. The Times sketched her “as well-versed in the politics of extraordinary rendition as she is in the very Brooklyn pursuit of homemade chile-passion-fruit sorbet”.

Mariam’s work was exhibited at Tate Modern in London, and the Guggenheim and MOMA in New York. One exhibit, “Afghanistan: A Lexicon”, was made in collaboration with Ashraf over Skype. Over 72 panels of text and photos created by the Ghanis, the history of Afghanistan is shown to be cyclical — an endless rotation of invasion, revolt, reform, collapse and recovery. A country cruelly frozen in dynamism.

She made films about the discovery of oil in Norway, and the melancholy difficulties of translation. She was born in New York, but identified “most with the border”. What Edward Said called the “essential sadness” of exile was there in Mariam, and in all her family. Perhaps that’s why the “Lexicon” had one telling absence from its story — the Ghanis themselves.

Ashraf had returned to the country with Rula in 2002 almost as soon as the Taliban were banished. First a finance minister under Hamid Karzai, he was an unsuccessful candidate for the presidency in 2009, and then the winner of that disputed election in 2014.

Afghanistan was a problem for the family in a way that America — where they had flourished — was not. America only needed Ashraf’s theories in the classroom. Afghanistan, Ashraf believed, could be saved by his theories. It was all in his book, and his TED talk. Opium farmers would make t-shirts. Embroiders in Kandahar would partner with Versace. Guns would become ploughshares. One day the daughters of Afghanistan would be like his own, free to study in America; free to make jam in Brooklyn; free to exhibit their work in Berlin.

Afghans were not fools. They only needed jobs. The people, Ghani said in 2005, were internationalist by temperament — “they’re much more sophisticated than rural Americans with college degrees and the bulk of Europeans.” Well, perhaps.

Becoming President gave Ghani the chance to govern the country that shone in his mind. Afghans would learn about sheep raising from New Zealand, and hydroelectricity from the Swiss. Afghanistan was a blank slate. Ghani began to doodle his beautiful diagrams on it.

Sigmund Freud once said there were two “impossible professions”: education and government. Ghani was a wonderful educator. He proved to be an impossible President. He micromanaged his illusions and his staff. He took anger management classes.

Why was he so angry? Was it the pressure — grinding and invidious — of watching his theories of the state become exposed as just another exile’s hopeless fictions?

Either way, he grew ever more solitary behind the blast walls, barbed wire, and checkpoints of the Arg. The library was his succour and support — one journalist described Ghani’s office, filled with open books on every surface, marked neatly with pencil annotations. This is what most intellectuals (quite rightly) do in a crisis. They retreat, like Michel de Montaigne did during the 16th century French wars of religion, to brood in their towers and libraries, hoping that solitude will yield new ideas. Montaigne, though, only advised the king of France, he had no pretensions to power itself; Ghani was supposed to be something like the king of Afghanistan.

At least, as everyone said, he was not corrupt. That was a blessing in a country where the MPs alone ritualistically stole over a billion dollars a year. But there was the rest of the family. Ashraf’s brother, Hashmat, and his nephew Sultan.

Hashmat will be remembered, not for driving a bulletproof Mercedes Limousine, or the 23,000 square feet of his Kabul home, but for the SOSi scandal. It was extraordinarily complicated; it involved hugely valuable rights to mineral deposits in Kunar province, illegal links between US special forces and militias — and the Ghani family. It was Hashmat who owned significant shares in the US company that wanted to buy the rights to the minerals, and it was President Ghani who signed off on the deal. Was it corrupt? “If there was a colour redder than red, that’s what colour this red flag would be,” said one American expert in procurement law.

Sultan, meanwhile, styled himself the President of ‘The Ghani Group’ on LinkedIn, and the co-founder of ‘The Institute for Afghan Women’ on his website.  Meanwhile, as the country started to tremble a few weeks ago, he shared photos of himself on Instagram walking towards a Learjet 75 Liberty.

Ashraf had promised to clean up grift when he first ran for President, but if it flourished in his immediate family, what hope did Afghanistan have?

When Ghani fled on Sunday he left behind half the population in poverty, a third of the population facing emergency levels of food insecurity, stagnant GDP, a massive trade deficit, a restive and furious countryside, and, in the words of one report, “a largely lawless, weak, and dysfunctional state”. Now the Taliban control it, down to the very last bumper car.

A few days before, Mariam Ghani’s latest film had its theatrical release in the United States. It’s title? What We Left Unfinished. For Ashraf — intellectual and politician, then, at last, a corrupted idealist — it was all unfinished.

How shocked, how distressed he looked, when he surfaced this week in the UAE, exiled once more. When his security team extracted him, he said, he was “in a condition where I couldn’t even put on my shoes”. Did Ashraf Ghani realise that the things he put his faith in, the codes by which he lived his life — ideas and books, globalisation and rational governance — had been diminished? That if the reports were true, and he really had left the country, not with his library, but with $169 million dollars, that he had maimed his life’s work, as well as Afghanistan?

Maybe he knew. All year, until almost the very end, he had promised his army could hold out against the Taliban, “forever“. But there was lucidity amidst the delusion.

“The future will be determined by the people of Afghanistan,” he told the BBC in February, “not by somebody sitting behind the desk, dreaming.”

He was wrong about the people of Afghanistan. Whether they stayed or fled, they would still dragged into the conflicts of others. But he was right about the dreamer behind the desk. Ashraf Ghani, unable to determine Afghanistan’s future, was describing himself.