Auto clear history when app is closed