Automatically clear history when the app is closed