U.S. stocks closed lower Friday, the last trading day of the year, with no S&P 500 sectors ending higher.

The S&P 500 closed about half a percent lower but still held gains of 19.4 percent for the year, its best since 2013. Information technology soared 36.9 percent and materials gained 21.4 percent as the top performers for 2017, while energy and telecommunications were the only sectors in the red for the year.

Selling suddenly accelerated in the last several minutes heading into Friday's close. Traders said there was no apparent reason for the broad sell-off, which hit all three major indexes. It took several minutes for stocks to settle before the Dow Jones industrial average finally ended about 118 points lower, erasing gains for the week.

Stocks were "hit very late in the day across different sectors," said Sahak Manuelian, managing director at Wedbush Securities. "I imagine it was just guys selling … reducing exposure on some the bigger winners of the year."

U.S. composite trading volume for the session was more than 1 billion shares below its 50-day average. Trading volume has been light all week as U.S. markets were closed Monday for Christmas and are closed next Monday for New Year's Day.

Apple and UnitedHealth each fell more than 1 percent as the greatest negative impact on the Dow, followed by Goldman Sachs. UnitedHealth is the third-best performer in the Dow this year. Boeing is first, followed by Caterpillar.

Goldman Sachs shares closed 0.68 percent lower after earlier falling more than 1 percent. The company disclosed in a Friday filing with the U.S. Securities and Exchange Commission that the financial giant expects fourth-quarter earnings to decrease by about $5 billion, primarily due to repatriation provisions in the new U.S. tax law President Donald Trump signed last Friday.

The law requires companies to repatriate, or bring back, foreign earnings, beginning in 2018, with the option of paying taxes on those earnings over eight years. The special, one-time tax rate is 8 percent for illiquid assets and 15.5 percent for cash.

The new law also cuts the corporate tax rate to 21 percent from 35 percent.

"It will be interesting to see how much short-term capital gains there will be in the first few weeks of January," said Dan Deming, managing director at KKM Financial. In addition, "People will be rebalancing their portfolios."