Save buffer on focus lost