Fix some error cases in the SyncEngine

Always cleanup properly when we bail out.

Also fix thread safety of the SyncJournalDB