London bade a flamboyant and madcap farewell to the Olympic Games with a romp through British pop and fashion, bringing the curtain down on more than two weeks of action that ended with America topping the sporting world with 46 gold medals.

There was another sellout crowd at the 80,000-capacity athletics stadium in east London late on Sunday for the final act of the tournament, and 300 million people were expected to tune in on televisions around the world.

Actor Timothy Spall read from Shakespeare's "The Tempest" dressed as war-time Prime Minister Winston Churchill, and after a London "rush hour" featuring real cars and trucks, Prince Harry entered to represent his grandmother Queen Elizabeth.

The Spice Girls, Take That and George Michael were among the acts taking part in an exuberant finale that sought to sum up Britain's enthusiasm for the Games despite reservations about the 9 billion pound ($14 billion) cost.

During a special eight-minute segment, the stadium was bathed in the colors and sounds of Brazil, as the Olympics looked ahead to 2016 when Rio de Janeiro is the host city.

But on Sunday and into the early hours of Monday it was time for London to say goodbye, and comedian Stephen Fry summed up the mood of many when he took to Twitter and wrote: "I don't want it to end *sob* *stamps foot*"

The circus-style ceremony was set to a British soundtrack of the last 50 years, featuring classic songs by Queen, the Kinks, the Beatles, Pink Floyd and more, and specially designed "pixel boxes" on every seat provided a spectacular light show.

It was always going to be a celebration for those in the stadium, rather than the showcase of the opening ceremony that featured a movie cameo by the queen and was a tribute to British history, culture and society in a message to the world.

NEXT GENERATION

The Who had the final word with "My Generation", an echo of the London 2012 motto which was "Inspire a Generation" as organizers and the government strive to ensure a lasting legacy that goes beyond expensive white elephants and unpaid bills.

Fulfilling promises of a "cheeky" and "cheesy" close, Eric Idle of Monty Python sang "Always Look on the Bright Side of Life", there was a giant inflatable octopus and a real-life human cannon ball flew through the air.

The Olympic flag was handed to Eduardo Paes, Rio's mayor, before International Olympic Committee president Jacques Rogge described the London Games as "happy and glorious" and declared them closed - the words taken from Britain's national anthem to the queen.

The Olympic Flame was extinguished, fireworks filled the sky, the athletes walked off and Britain prepared to return to the reality of an economic recession temporarily buried in the inside pages of the newspapers.

The main stadium was the setting for some of the most spectacular moments of the Games, including Jamaican sprint king Usain Bolt defending the 100, 200 and 4x100 meters titles he won in Beijing, the latter in a world-beating time.

British supporters will also cherish memories of the venue, where Somali-born runner Mo Farah won the 5,000 and 10,000 double to deafening roars and was celebrated as a symbol of the capital's multi-culturalism.

The hosts won 29 golds to take third place in the rankings, their best result for 104 years, helping lift a nation beset by severe spending cuts and worried about social stability a year after violent riots swept parts of the capital.

U.S. President Barack Obama called British Prime Minister David Cameron to congratulate the country on what he called "an extremely successful Olympic games, which speaks to the character and spirit of our close ally".

PHENOMENAL PHELPS

Many will remember London 2012 for the record-breaking exploits of American swimmer Michael Phelps, who took his life-time medal haul to 22 including 18 golds, making him the most decorated Olympian in history.

His tally helped the United States to the top of the Olympic table with 46 golds to second-placed China's 38, reversing the order of the Beijing Games in 2008.

There was, of course, Bolt, the biggest name in athletics and a charismatic ambassador for sprinting.

After winning the 4x100 he went on to a London nightclub to delight dancing fans with a turn as a DJ, shouting out "I am a legend" to the packed dancefloor.

Britons may recall Andy Murray demolishing world number one Roger Federer at Wimbledon to win the men's singles tennis gold, while Jessica Ennis, the "poster girl" of the Games, won the women's heptathlon on the first "super Saturday".

Despite concerns about the creaky transport system and a shortfall of private security guards, which forced the government to call in thousands of extra troops to help screen visitors, the Games passed by fairly trouble-free.

A furor over empty seats at several Olympic venues blew over, especially once the track and field showcase kicked in and drew capacity crowds for virtually every session.

Even the weather improved as the Games wore on. Bright sunshine graced the closing weekend of a festival that has helped to lift spirits in Britain.

TRIUMPH, TRAUMA

It was not all about triumph, however. Many tears shed by athletes and the public were of sorrow, not joy, as medals were narrowly missed and controversial decisions left athletes convinced they were wronged.

At the closing ceremony, a highlights video reel included images of South Korea's Shin A Lam alone and distraught on the fencing piste after a timekeeping error contributed to her defeat in an epee semi-final.

China's hero Liu Xiang suffered heartache again after crashing into the first barrier of the 110 sprint hurdles four years after he withdrew from the heats in Beijing due to injury.

Eight Asian badminton players were controversially expelled from the Games after not trying hard enough to win matches, having broken the spirit, but not the rules of their sport.

And China bowed out of the Games with a swipe at the critics who accused teenage swimming sensation Ye Shiwen of doping after her times rivaled the top U.S. men.

Aged just 16, Ye set a world record, a Games record and won two gold medals in the women's individual medleys, but her victories were overshadowed by questions and insinuations of cheating. There was no evidence that she had broken any rules.

The head of the Chinese delegation to London, Liu Peng, said the accusations were totally unfounded.

"This is really unfair. This is groundless," Liu told a news conference on Sunday. "There are individuals and media that are accusing, unfounded, our Chinese athletes."