The Vancouver Winter Olympics ended in spectacular triumph on Sunday with a closing ceremony that mixed traditional pomp with self-effacing humour and put the icing on 17 days of unrelenting drama and action.

The President of the International Olympic Committee Jacques Rogge declared the Games ‘excellent and very friendly’ in a closing speech that also paid tribute to the Georgian luger who was killed in a training accident on the day of the Opening Ceremony.

‘We have shared the grief of an Olympic dream cut short. The memory of Nodar Kumaritashvili will always be with us,’ Rogge said before closing the Games and inviting the world's athletes to reassemble at Sochi, Russia for the 2014 Winter Olympics.

Millions of Canadians had already begun celebrating long before the closing ceremony began after the host-nation defeated the United States 3-2 in a heart-stopping end to the men's ice hockey competition to capture a record 14th gold medal.

Sidney Crosby scored the winner after the Americans had equalised 24 seconds from the end of regular time to force the match into overtime and threaten to spoil the Canadian national party.

‘You dream of that moment a thousand times growing up,’ Crosby said. ‘For that to come true is pretty amazing.’

The hockey was one of just two medals decided on the last day of competition with Norway's Petter Northug winning the first in the men's 50km cross country ski race at Whistler after the closest ever finish to the lung-bursting event.

Northug sneaked past Germany's Axel Teichmann right at the finish line to win the gold by just 0.3 seconds with Sweden's Johan Olsson taking the bronze.

Canada were already assured of finishing top of the standings for the first time at either a Winter or Summer Olympics but beating their American neighbours was the perfect ending for the hockey-crazy host nation.

‘Our last one (gold) will be remembered for generations,’ Vancouver's organising chief John Furlong said at the ceremony.

The Canadian victory set a new record for golds won at a single Winter Games, surpassing the previous mark of 13 jointly held by the Soviet Union (Innsbruck, 1976) and Norway (Salt Lake City, 2002).

The U.S. also set a record for the most overall medals at a single Winter Olympics, finishing with 37, one more than Germany in 2002, but that was of little consolation to members of the beaten hockey team.

‘It's the biggest game any of us has ever been in and it's devastating,’ American defenseman Jack Johnson said.

The final provided an unforgettable ending to the competition and transfixed the whole of North America with U.S. President Barack Obama and Canada Prime Minister Stephen Harper even wagering a case of beer on the outcome.

Vancouver was transformed into a sea of red and white maple leaf flags and sweaters as thousands of people flooded into the central business district in preparation for the most eagerly awaited match of the Games.

Every restaurant and bar was packed to overflowing after patrons queued for more than four hours to get the best seats while local television broadcast pictures of American and Canadian troops in Afghanistan watching the game.

The party atmosphere continued at the closing ceremony at BC Place with the hosts poking fun at themselves in a two-hour extravaganza that was laced with self-effacing humour.

Michael J. Fox and William Shatner mocked their countrymen's penchant for politeness while giant inflatable beavers and moose joined in an game of hockey that took an irreverent view of the country's obsession with the sport.

There were some more sombre moments. Figure skater Joannie Rochette carried Canada's flag after winning a bronze despite still griving the sudden death of her mother and the crowd richly applauded the tributes to Kumaritashvili.

‘Vancouver had extraordinary embrace, something I have never seen on this scale,’ Rogge told a news conference.

The triumphant ending was in stark contrast to the gloomy mood of just a week ago.

The death of Kamaritashvili before the opening ceremony, a lack of snow in the first week and the failure of the hosts to win a stack of early medals was all forgotten after Canada won 10 golds in the last seven days and the initial pessimism snowballed into one giant party.

‘These Olympic Games have lifted us up,’ Furlong said.

‘If the Canada that came together on opening night was a little mysterious to some it no longer is. Now you know’