U.S. stocks closed higher Friday, with shares of Amazon surging following its quarterly earnings results. The Dow, S&P 500 and Nasdaq ended October with monthly gains despite the government shutdown.