CHICAGO (AP) — The Detroit Lions closed a losing season with a victory on Sunday as Matthew Stafford threw for 298 yards and three touchdowns and Calvin Johnson had 137 yards receiving in a 24-20 win over the Chicago Bears.

Detroit (7-9) avoided a last-place finish in the NFC North with its sixth win in eight games. Whether the Lions bring back coach Jim Caldwell for a third season remains to be seen.

He led them to a rare playoff appearance last year, but a 1-7 start put his future in doubt.

Caldwell survived a midseason purge that saw offensive coordinator Joe Lombardi get fired and ownership drop the ax on president Tom Lewand and general manager Martin Mayhew the following week.

The Lions intercepted Jay Cutler three times, and held on after the teams started trading scores in the second half. They took a 24-17 lead on Eric Ebron’s 1-yard touchdown catch in the fourth quarter.

It was a four-point game when Detroit’s Glover Quin intercepted Cutler with just under two minutes remaining, and the Lions hung on from there.

Chicago (6-10) lost for the fourth time in five games and finished last in the division despite showing progress in its first season under coach John Fox and general manager Ryan Pace.

Stafford, who got into a groove late in the year with Jim Bob Cooter as offensive coordinator, completed 28 of 39 passes without an interception. Johnson had 10 catches, including a lunging 36-yard touchdown grab.

Matt Prater kicked a 59-yard field goal — the longest ever at Soldier Field, according to STATS.

Cutler was 17 of 23 for 245 yards and two touchdowns with top receiver Alshon Jeffery on injured reserve and Eddie Royal out with an illness.

Matt Forte had 76 yards rushing and 34 receiving in what could be his final game for Chicago, given his age (30) and expiring contract, and the Bears finished 1-7 at home.

Trailing 10-0 at halftime, the Bears tied it midway through the third when Cutler hit a leaping Josh Bellamy down the middle for a 34-yard touchdown.

That started a run in which the teams combine to score on five possessions.

The Lions briefly regained the lead when Johnson got behind Tracy Porter along the left sideline and lunged to snag a 36-yard touchdown from Stafford, making it 17-10 with just over a minute left in the quarter.

The Bears tied it again early in the fourth on a 23-yard pass from Cutler to Forte. But Detroit’s Joique Bell turned a short pass into a 35-yard gain, helping set up a 1-yard TD reception Ebron.

Chicago’s Robbie Gould then kicked a 34-yard field goal to make it 24-20 with 5:39 left.

(© 2016 by STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.)