Added code to clean out old events on shutdown of app.