The Olympic flag was handed over by Sochi's mayor to the mayor of Pyeongchang, South Korea, host of the next Winter Olympics, and a huge animatronic bear, one of the mascots to these Games, blew out the flame in a version of the Olympic cauldron.
International Olympic Committee President Thomas Bach spoke to the crowd, commending Russia and President Vladimir Putin for their hosting of the Games, praising "a new Russia ... efficient and friendly, open to a new world."
Sunday's closing spectacle included a clever reference to the opening-ceremony snag in which one of the Olympic rings did not open.
Dancers created the rings, with one closed. Would it open? After a long pause, it did. As they did at the opening of the Games, each nation's athletes paraded in. Despite a devastating loss to Canada, the U.S. women's hockey team remained in Sochi to take part in the ceremony. Julie Chu, a four-time Olympian who was part of the silver-medal-winning team, was chosen to carry the U.S. flag.
Medals were bestowed and clean sweeps celebrated, including Norway's dominance of women's cross-country skiing, in which Marit Bjoergen won gold, and Russia's medal sweep in men's cross-country. Alexander Legkov won gold in the men's 50-kilometer race to give the host nation its first cross-country gold at the Sochi Games.
The proceedings took a turn for the surreal with a Marc Chagall painting shown on stage and masked dancers cavorting on stilts to violin and viola. Then a grand piano arose from below stage for a stunning performance of Rachmaninoff. Russian ballet and literature also got their turn in the spotlight.
A big top was erected onstage as performers including unicyclists and gymnasts tumbled in for a celebration of circuses.
The ceremony began, symbolically, at 20:14 (8:14 p.m.) local time. (See a preview of the proceedings, live, below.)
The host country had much to celebrate as the Games wrapped. Russia ended as the overall champ, with 33 medals. The U.S. was second with 28.
The ceremony will be broadcast on the West Coast at 8:30 p.m. Sunday. (Here's a version of our real-time coverage for mobile users.)