added saving during app close.