Buffalo Bills quarterback Josh Allen (17) celebrates after running back LeSean McCoy scored a 5-yard touchdown during the second half of an NFL football game against the Miami Dolphins, Sunday, Dec. 30, 2018, in Orchard Park, N.Y. (AP Photo/Adrian Kraus)

ORCHARD PARK, N.Y. (AP) — As they bid farewell to their unquestioned leader, defensive tackle Kyle Williams, the Buffalo Bills also enjoyed a glimpse into an encouraging future.

Rookie first-round draft picks Josh Allen and Tremaine Edmunds played a significant role in ensuring Williams headed into retirement on a high note after a 13-year career in Buffalo. The young players led the Bills to a 42-17 rout over the Miami Dolphins on Sunday.

Allen had a career-best three touchdown passes and scored two more rushing, while Edmunds had a one-handed interception and added a sack. They put the finishing touches on a 6-10 season in which the rebuilding Bills won four of their final seven games.

"We're excited for where this organization's going," safety Micah Hyde said. "This franchise is headed in the right direction. It's got younger guys, older guys, leadership, weapons and we're only going to get more."

With all that to look forward to, Hyde was asked whether he could convince Williams to stick around.

Hyde broke into a smile and said, "I'm going to talk to him real quick."

Williams, with his three sons sipping Gatorade at his locker, had no second thoughts about choosing family over football. He also reflected on how the Bills are in good hands.

"I'm excited. And I think that's one thing that made this the hardest decision," Williams said, referring to the team and culture coach Sean McDermott and general manager Brandon Beane are building. "We have so many young guys, first-year players, second- and third-year players that I can't wait to watch. I can't wait to be around as much as they'll have me to see what this football team will do."

A teary-eyed Williams was the last player out of the tunnel before kickoff, and then was greeted by his wife, Jill, and five children.

He then enjoyed a chance to contribute on defense and offense by registering one tackle for a loss and catching a 9-yard pass — the first of his career — with under five minutes left.

Williams left the field with 1:19 left to a crowd chanting "Thank you, Kyle!" and then, afterward, circled the stands to greet and thank the fans who remained.

He was part of a Buffalo defense that had four sacks and forced four turnovers, including three by Miami quarterback Ryan Tannehill. And the 42 points were Buffalo's most since a 45-16 win over San Francisco on Oct. 16, 2016.

Miami (7-9) thoroughly unraveled except for the final minute of the second quarter, in which it scored twice in a span of 16 seconds to tie the game at 14.

The Dolphins now enter an offseason of uncertainty, with questions raised about the futures of coach Adam Gase and vice president of football operations Mike Tannenbaum as well as Tannehill.

Dolphins chairman and managing partner Stephen Ross declined to comment on his way out of the stadium.

Gase and most of the players had little else to say after they closed a wildly inconsistent season. After opening with three wins, Miami finished with three losses and lost their final seven road games.

"I'm not even thinking about that right now because we just got drummed on the road," Gase said, when asked of his future.

Tannehill finished 18 of 31 for 147 yards with two interceptions and a lost fumble. He did score by catching a 3-yard pass from Kenny Stills with 54 seconds left in the second quarter. Dolphins safety Reshad Jones scored two plays from scrimmage later on a 29-yard interception return.

Miami's defense allowed 381 yards to finish the season with a franchise-worst 6,257 yards allowed. Its previous worst was 6,122, set in 2016.

Though the Bills never trailed, Allen's 5-yard touchdown pass to Robert Foster six minutes into the third quarter broke a 14-14 tie to put Buffalo ahead for good. Allen then secured the victory with a 30-yard TD run to increase Buffalo's lead to 35-17 with 11:13 left in the game.

He finished 17 of 26 for 224 yards passing, including 18- and 26-yard touchdowns to Zay Jones, and an interception. And he added 95 yards rushing, including a 1-yard touchdown to open the scoring.

EJECTIONS

Dolphins linebacker Kiko Alonso and defensive end Robert Quinn and Bills offensive tackle Jordan Mills were ejected following a late hit on Allen during the third quarter.

Allen was already sliding when Alonso dived in front of him and kicked the quarterback in the helmet. A scuffle broke out amid a group of players, and Quinn came running in at full speed from about 20 yards out and dived atop the pile. Alonso was ejected for kicking Allen, while Quinn and Mills were ejected for personal foul penalties.

RUNNING QBS

Allen's eight rushing touchdowns this season were the second-most by a quarterback in the Super Bowl era. Cam Newton had 14 in 2011. Robert Griffin III, in 2012, and Vince Young, in 2006, each scored seven.

With 630 yards rushing in just 11 starts, Allen topped the single-season team record for yards rushing by a quarterback. Tyrod Taylor had 580 yards two years ago.

INJURIES

Dolphins: CB Torry McTyer did not return and was being evaluated for a concussion after being bowled over by Buffalo's Logan Thomas. McTyer was looking up the field and didn't see Thomas coming in from his right.

Bills: CB Tre'Davious White did not return after sustaining a head injury in the final minutes of the first half. White was knocked over by Kenyan Drake while lowering his head as he tried to make an open-field tackle.