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).
E_FAIL is evil. If this case is hit, that error code won't tell you much. I always try to find some better error code than E_FAIL.