RIO DE JANEIRO — Penny Oleksiak led Canada to the podium four times at the Rio Olympics. It was only fitting then that she led the Canadian delegation into Maracana Stadium for the closing ceremony of the Summer Games on Sunday night.

On a blustery and rainy night, Oleksiak carried the Maple Leaf and led a Canadian contingent that surpassed its goal in Rio of finishing in the top 12 in the overall medal count.

The rest of the athletes followed the flag-bearers, with the Canadians wearing their trademark red mittens. Despite the poor weather, the athletes seemed to be in a festive mood and ready to let off steam.

And the Canadian athletes deserved to. Canada earned 22 medals — four better than the 18 won in London four years ago — and was 10th in the medal standings.

"I'm super honoured just to be able to carry the flag for Canada and lead all these athletes who've worked so hard to get here," said Oleksiak, a 16-year-old native of Toronto.

She started the haul by helping Canada win bronze in the 4x100 freestyle relay on the first Saturday of competition, then rocketed to silver in the 100 butterfly the following night. There was another relay bronze before she surged to gold in the 100 freestyle on the penultimate day of swimming.

Oleksiak became Canada's most decorated athlete at a single Summer Games and appears on track to eventually become Canada's most decorated Olympian ever. Speedskater Cindy Klassen and Clara Hughes, in both speedskating and cycling, are tied for the most career Olympic medals with six apiece.

Lagging behind their winter counterparts since the turn of the century, the 22 medals won by Canadians is equal to the most at a non-boycotted Games after Atlanta in 1996.

"Our athletes have proved we're one of the best teams ever sent to any Olympic Games," chef de mission Curt Harnett said Sunday. "They delivered a historic performance."

Canada's women led the way with 16 medals, including the first dozen. Along with Oleksiak, other women medallists included Rosie MacLennan, who defended her trampoline gold from London, and wrestling champion Erica Wiebe. The women also provided bronze medals in the team sports of soccer and rugby sevens.

"Canadians, especially our young women and girls, were incredibly inspired by our female Olympians who were a force to be reckoned with throughout the Games," Prime Minister Justin Trudeau said in a statement. "I know the impact of our athletes' accomplishments will live on and be replayed in playgrounds and on sport fields for many, many years to come."

Even Eric Lamaze of Schomberg, Ont., earned showing jumping bronze aboard Fine Lady 5, a 13-year-old mare.

Oleksiak joins 21-year-old triple-medal sprinter Andre De Grasse of Markham, Ont., the first Canadian to win three sprint medals at a single Games, as Canada's athletes to watch heading into Tokyo in 2020.

The COC said previously a top-12 finish was a stepping stone to top eight, which required 29 medals in Rio.

"We've talked about top eight in the past," Smith agreed. "There's a price tag to that. We'll have to look at that price tag and see if that's something we can do."

The Canadian taxpayer is the largest single contributor to their Olympic teams. The federal government spent almost $200 million in 2015 on its athletes and hosting international events for them.

Own The Podium directs roughly $36 million of Sport Canada funding annually based on medal potential to Olympic and Paralympic summer sport federations, plus an extra $6 million to summer-team sport.

COC chief executive officer Chris Overholt said Sunday that $105 million was invested in summer and winter sport over the last four years via corporate sponsorships.

The absence of multiple Russians suspended for doping and a slingshot effect from the 2015 Pan American Games in Toronto, where the host team was second to the U.S. with 217 medals, were perhaps factors in Canada's medal haul.

The COC pays bonus money to medallists of $20,000 for gold, $15,000 for silver and $10,000 for bronze.

Each athlete on the soccer and rugby teams receive $10,000 for their bronze medal, so the COC's total payout for Rio will be $750,000.

The coaches of medallist are also rewarded at half the rate of their athletes. That bill comes to $137,500.

The Paralympic Games are scheduled for Sept. 7-18 in Rio despite recent budget cuts.

In the final day of competition, Canada's Eric Gillis finished 10th in the men's marathon. Gillis, from Antigonish, N.S., finished in two hours 12 minutes 29 seconds, just off the Canadian record set by Toronto's Jerome Drayton in 1975.

Also, Leandre Bouchard of Alma, Que., was 27th and Raphael Gagne of Quebec City did not finish in the Olympic mountain bike race.