Add async db sync to fix data loss on unexpected exit