Save buffer when focus lost