The S&P 500 capped off its best week since April with a record close, ultimately finishing with a gain of 3.6%.