Bolt, 29, had won the 100m and 200m in Rio and is the only man to win all three sprint events at three Games. He combined with Asafa Powell, Yohan Blake and Nickel Ashmeade to finish in 37.27 seconds.
Japan won a surprise silver and the USA were disqualified to hand Canada bronze and lift Britain up to fifth.
"There you go. I'm the greatest," said Bolt, after bringing an end to one of the most astonishing Olympic careers of all time.