KANSAS CITY, Kan. — Three straight finishes outside the top 10 for Denny Hamlin these days counts as a rough patch.

He was once again smooth as they get Thursday night.

Hamlin hung around the front of the pack all night, avoiding trouble that cost several playoff contenders in the final stage, then breezed past Kevin Harvick for the lead in the closing laps. Hamlin then held off charging Brad Keselowski for his NASCAR Cup Series-leading fifth victory of the season and 42nd overall. He also won for the second straight time at Kansas Speedway.

“I don't know we had the best car. We definitely had a top-three car all day,” Hamlin said after his burnout in front of the empty grandstands. “We just went for it there at the end. The pit crew did an amazing job getting us out there in front.”

Hamlin had struggled the past three weeks, failing to finish better than 12th. But after showing good speed early, his Joe Gibbs Racing team made all the right calls during a crash-filled final stage. Keselowski finished second and Martin Truex Jr. came across third. Harvick wound up sliding to fourth and Erik Jones capped a big day for the Gibbs boys in fifth.

William Byron led the race as he chased his first career race, but he slide backward after a late caution and wound up finishing 10th. Alex Bowman also made a charge to the lead but finished behind Aric Almirola and Cole Custer in eighth.

The youngsters wound up leaving it to the veterans to battle it out over the final laps.

“We got to the lead but we just went dead sideways after about four or five laps,” said Harvick, who had been tied with Hamlin with four wins. “We were just holding on hoping for another restart, because we could hang for a couple laps.”

Truex may have had the fastest car on the track by the end of the night, which began with temperatures in the mid-90s and a heat index approaching triple digits. But he ran out of time trying chase down his teammate.

“It would have been difficult to pass him,” Truex said about Hamlin. “It was a battle all night just to get track position. These things are so difficult in traffic. You lose a few more spots than you hope on a restart and you just have to dig.”

Joey Logano led early before his night really ended in disaster — and took some playoff contenders with him.

His problems began when a tire got loose on pit road during the first stage, sending him to the back. He was working his way forward early in the final stage when his left front tire went down, sending Logano into the outside wall. Matt DiBenedetto and Jimmie Johnson, the last two drivers on the good side of the playoff cut line, sustained heavy damage as the field checked up. So did Austin Dillon, who was the surprise winner last weekend at Texas.

“I'm pretty freaking irritated. We’ve had garbage luck the last few weeks," DiBenedetto said. “We have no horsepower. It takes us 45 minutes to get going. The restarts as just wild. But that's what is happening.”

Logano said he felt his tire going down just before green but thought “it wasn't bad.”

“Maybe it was bad judgment on my part,” Logano said, “and I didn't want to lose any track position for something that wasn't bad. It's one of those judgment calls. I just feel bad for everyone else.”

Another wreck during the next always-chaotic Kansas restart collected Ryan Preece, Chris Buescher, Ryan Newman and Christopher Bell. Preece hit the inside wall with such force that his car leaped several feet into the air.

It would have been an exciting show for fans if there was any. After about 20,000 wore masks and braved stifling heat in Texas, the grandstands were again empty at Kansas. Soaring numbers of positive COVID-19 tests forced speedway officials to run this weekend — including upcoming races in the Xfinity, Truck and ARCA series — without any fans.

The next race at New Hampshire can have about 19,000 fans. The following doubleheader at Michigan will not have any.

Kyle Busch finally had something go right during his frustrating season. The defending series champ, whose only win in his last 41 starts in the Cup Series came in last year's finale, held off Hamlin and Truex to win his first stage this year.

It was another race between teammates on Stage 2. This time, it was Keselowski getting around Team Penske teammate Ryan Blaney — who was dominant at Texas but failed to win — on the penultimate lap to take the stage.

Ricky Stenhouse Jr.'s challenging year continued when he went to the garage early with a mechanical problem. It also was a rough night for Bubba Wallace, who spun early in the race coming out of Turn 4 and then plowed into Matt Kenseth when he spun in the middle of the same turn early in the final stage.

“We’ve had some really bad weeks,” Stenhouse said. “Lost the balance a little bit but felt like we were pretty close. But I don’t know, a fire started in the cockpit. Something electrical in the dash.”

___

More AP auto racing: https://apnews.com/apf-AutoRacing and https://twitter.com/AP