Added auto save on close.

Closing the app now saves the events.