The reason Doc Hudson didn't want Lightning McQueen to stay in Radiator Springs in the first place is because Hudson was once a great race car himself: the Hudson Hornet, 3-time winner of the Piston Cup in the 1950s. The fallout from a crash ended his career: once he had recovered, he found the racing world wasn't interested in him anymore; he has never overcome his bitterness, and no one else in town has ever known about his past.
While everybody's celebrating the restoration of the town - spearheaded by Lightning - the media and his transporter Mack arrive to pick Lightning up and get him to California. (Hudson had alerted them to his location.)
In the final Piston Cup race Lightning is at first uninspired until he realizes that Hudson and many of the townsfolk have come to help him out in the pits. On the last lap, he's within spitting distance of the checkered flag, far ahead of his two competitors - but then he sees that Chick Hicks has intentionally rammed veteran The King off the road, causing a crash, because he didn't want to come in second. Realizing that the King might suffer the same fate Hudson did, Lightning heads back and pushes him to the finish line so he can finish with dignity. Chick thus wins the race, but no one respects him for it.
Lightning is hailed as a hero and is even offered the coveted Dinoco endorsement deal, but he stays with his old sponsor...and with Radiator Springs, reopening the old Wheel Well Motel with Sally - as his success has brought massive attention to the forgotten town and its folk.
(During the end credits, we see several epilogue segments. Among other things a racing museum opens in town, a drive-in theatre highlights car-themed versions of previous Pixar films, we see the fate of the car gang that separated Mack from Lightning in the first place, and finally after the last credits, the fate of the husband-and-wife cars that passed through town lost.)
(Links open in new window)
Read more about this film at The Internet Movie Database.