Improved timing of clearing out the session cache.