Destroy the models immediately when returning from the settings dialog

Previsouly, there was a possibility that the SQL cache might be involved in some
activity at the time the nukeModels() was called. However, due to the delayed
deleting, the Model's actual destructor (which destroyes the cache, which ends
the active transaction) might be run only after the setupModels() has finished,
which meant that the newly-created sqlite connection hit a locked database.

Thanks to Stefan Kögl <stefan.koegl@tu-dortmund.de> (hotte on IRC) for reporting.
Be nice to the IMAP server and logout when changing settings
sql: unregister the DB from the Qt's registry as well

There's still one more warning about the connection being in use. I obviously
dislike this reinventing of RAII in here (or rather in QSqlDatabase, because one
apparently cannot do it without going through its global registry, yuck!).