The United States, which had a frustrating swimming world championships, ended on a high note Sunday with a world record in the women's 4x100 medley in the last event of the eight-day championships.
The Americans swam a time of 3 minutes, 49.34 seconds, breaking their own old mark of 3:49.63.
Regan Smith, Kate Douglas and Gretchen Walsh swam the first three legs with Torri Huske taking the anchor.
The United States finished with nine gold medals and 29 overall, ahead of Australia with eight gold and 20 overall. France and Canada were next in the gold-medal count with four gold medals.
Summer McIntosh won all four medals for Canada, while Leon Marchand of France left the worlds with what he came for: two individual gold medals. They were the two clear stars through the week.
The 18-year-old McIntosh came away one gold shy of her quest to win five. Still, she is only the second woman to win four individual golds at a world championships.
Her only blip was finishing third to American Katie Ledecky in the 800 freestyle Saturday.
Marchand narrowly missed the 400 individual medley final but was dominant once he got there, winning in 4:04.73.
American swimmers have battled a case of "acute gastroenteritis" picked up at a training camp in Thailand. The malady clearly affected the team's performances, with only five gold medals through six days, but the United States won four in the last two days as the swimmers' health seemed to improve.
"This is the best way to end the meet," Walsh said. "And I feel like we have such a good opportunity when you have this stacked group of women closing it out on a relay like this.
"We're going to leave Singapore with a smile on our faces."
Sunday's closing day featured eight finals and victories for seven different teams.
And 12-year-old Chinese swimmer Yu Zidi, in an astounding performance, finished fourth in all three of her individual races. She did pick up a bronze medal in a relay, where she swam in the prelims but not in the final.
The Associated Press contributed to this report.