US stocks closed out their best week of the year with more gains on Friday and climbed to the cusp of their records.