Delete settings engine streams safely

Only delete settings engine streams after database commits.

Fix a few other minor bugs along the way that probably aren't worth their own pull request (UI thread issues that could rarely occur, minor correctness things, and ensure logutil is initialized before we could ever call ExitOnFailure).