AVONDALE, Ariz. – With the end of his career possibly just one week away, Matt Kenseth showed he still knows how to win with a victory in Sunday’s Can-Am 500 at Phoenix Raceway.

Kenseth, who only a few weeks ago revealed he’d be taking a hiatus from NASCAR at the conclusion of the season after losing his seat at Joe Gibbs Racing to Erik Jones next year, scored the 39th victory of his career Sunday after an intense late-race battle with Chase Elliott.

“What a storybook ending,” Kenseth said. “I wasn’t sure I was quite ready for this, to move on to something (else) next year. Honestly God made the decision for me. He put me here for a reason and he’s taking me out for a reason. It’s just been an incredible journey.”

Elliott needed a victory to earn a spot in the Championship 4 next Sunday at Homestead-Miami Speedway and he did everything in his power to do that, including show the bumper to the man who moved him out of the way at Martinsville Speedway, Denny Hamlin.

Hamlin had the dominant car throughout much of Sunday’s race, leading a race-high 193 laps throughout the course of the event as he tried to punch his ticket to race for a championship at Homestead. Things changed for Hamlin during the third and final stage of the race following a caution on lap 228 for Trevor Bayne slamming the wall.

All of the leaders hit pit road, with Kenseth managing to beat Hamlin off pit road to take the race lead. Kenseth was still in the lead when the caution flag waved again with 74 laps left for debris.

The restart came with 69 laps to go and Kenseth held serve again until another caution when Chris Buescher crashed entering turn three. The incident led to a brief red flag period when a broken brake rotor from Buescher’s Chevrolet caused part of the SAFER barrier on the backstretch to catch fire.

Another restart came with 54 to go and Kenseth again held the lead as Elliott began challenging for the lead after passing Hamlin for second. The battle was halted again with 51 laps left when Cole Whitt hit the wall to bring out the caution flag.

The race resumed with 47 laps left and Kenseth again held serve, but behind him the battle was on between Hamlin and Elliott. After Truex got by Elliott for second on the restart, Hamlin also slipped by Elliott to take over third.

With 38 laps to go disaster struck for Hamlin when, after contact with his Martinsville rival Chase Elliott, Hamlin’s Toyota cut down the left-front tire, sending him into the wall in turn three. With the damage too severe to continue, Hamlin’s shot at winning a championship was officially over.