The S&P 500 closed lower but held in the green for 2015 after ending there Wednesday. The index failed to hold intraday attempts at gains as energy led all sectors except health care lower.

Energy closed down nearly 1 percent, holding gains of 4.6 percent for the week. The sector is still more than 20 percent lower for the year so far as the worst performer in the S&P 500.

The Nasdaq composite held slight gains as Facebook, semiconductor and biotech stocks advanced.

Year-to-date, weekly performance

The Dow Jones industrial average failed to hold intraday attempts at gains as Chevron, Exxon Mobil and Nike weighed.

Oil remained near multi-year lows, but extended recent gains. U.S. crude oil futures settled up 60 cents, or 1.60 percent, at $38.10 a barrel, for a 9 percent weekly gain. Brent was last trading just below $38 a barrel. Natural gas inventories declined slightly from the previous week, according to the EIA.

The stock market closed at 1 p.m., ET, for Christmas Eve and remains closed Friday for Christmas Day. Oil settled early at 1:30 p.m., and the bond market was scheduled for a 2 p.m. close.

"I think today's really about retail. It's really the last day for (investors) to focus on the Christmas season," said JJ Kinahan, chief strategist at TD Ameritrade. He noted unseasonably warm weather in most of the United States may encourage more shopping on Dec. 26, a day he said has recently become more important for retail.

The U.S. dollar index was about 0.4 percent lower against major world currencies, with the euro near $1.095 and the yen at 120.27 yen against the greenback.

As of Thursday's close, the S&P 500 was up 0.1 percent for the year so far, while the Nasdaq composite was up about 6.6 percent year-to-date. The Dow Jones industrial average was 1.5 percent lower for 2015.

In corporate news, Nike's 2-for-1 stock split took effect Thursday. Class B of the new shares closed down 1.8 percent.