Save the history even if Escape was pressed