The 27-year-old now has 22 medals - 18 gold, two silver and two bronze - 12 years after his Games career started in Sydney when he was fifth in the 200m Butterfly.
Six golds and two bronze medals in Athens were followed by his historic eight gold medals in Beijing four years later.
When he was introduced before the final race of his career, his composure appeared to slip slightly.
He swam the butterfly leg and handed over to Nathan Adrian in first place for the freestyle as the USA clinched another title in 3:29.35.
The USA also won the women's 4 x 100m Medley Relay from Australia and Japan in a new world record.