Unified save method when entering background vs. closing app.