save history on exit bug