Stocks closed lower on Wall Street for the first time this week Friday, but still notched their best weekly gain since June.

Technology led the selling, which snapped a four-day rally as traders tempered their worries about economic fallout from the virus outbreak that originated in China.

On Friday:

The S&P 500 fell 18.07 points, or 0.5%, to 3,327.71.

The Dow Jones Industrial Average dropped 277.26 points, or 0.9%, to 29,102.51.

The Nasdaq slid 51.64 points, or 0.5%, to 9,520.51.

The Russell 2000 index of smaller company stocks lost 20.68 points, or 1.2%, to 1,656.78.

For the week:

The S&P 500 rose 102.19 points, or 3.2%.

The Dow gained 846.48 points, or 3%.

The Nasdaq climbed 369.57 points, or 4%.

The Russell 2000 added 42.72 points, or 2.7%.

For the year:

The S&P 500 is up 96.93 points, or 3%.

The Dow is up 564.07 points, or 2%.

The Nasdaq is up 547.91 points, or 6.1%.

The Russell 2000 is down 11.69 points, or 0.7%.