MainViewModel: added destructor to handle saving prefs and ensuring the ...

...application shuts down.