U.S. stocks closed solidly higher to cap off a week that saw the S&P 500 notch its fourth-straight weekly gain.