Added blocking of db sync when shutting down