The S&P 500 barely avoided a bear market. Here's how stocks have fared after previous 'near misses'