Save when switching file or mode.