Stocks slipped on the final day of trading for 2023 in what has been a surprisingly strong year of gains on Wall Street.