CHICAGO (AP) — Valentín Castellanos had a goal and an assist, Maximiliano Moralez had two assists, and New York City FC beat the Chicago Fire 4-3 on the final day of the regular season Sunday.

NYCFC will play Orlando City in the Eastern Conference semifinals and Chicago (5-10-8), which is winless in its last six games, was eliminated from MLS playoff contention.

Castellanos, who recorded his first career hat trick and had an assist in the last game against the New York Red Bulls on Nov. 1, ran onto a misplayed ball by Chicago’s Miguel Ángel Navarro and tapped in a roller from near the spot for the tiebreaking goal in the 77th minute.

Alexander Callens headed home a corner kick by Moralez to open the scoring in the 15th minute and Gary Mackay-Stevens scored in the 32nd to put New York ahead 2-0. Mackay-Stevens has two goals this season, both in the last two games.

Chicago’s Robert Beric answered with a goal about a minute later but Jesús Medina blasted a rising first-timer off a pass from Moralez to give New York City a 3-1 lead in the 37th minute.

Przemyslaw Frankowski scored in the 42nd and then again in the 43rd to tie it at 3.

New York City (12-8-3) has won four consecutive games for the first time since a five-game win streak from Aug. 17-Sept. 7 of last season.