Quite annoying, and I know that you'll just say "Ohh, well just don't make it not unexpectedly shutdown" but you could just save the file when a preference is changed.
The default value for saveSettingsOnSet (Preferences -> General -> Save options to disk whenever they change) is true. Unless you've changed that setting, mafia should already be doing what you're asking for.
Nowadays, there are also caches in hardware. Do those guarantee that data will be written in case of power loss? I suspect you don't get that unless you are buying very expensive stuff.