Made sure the database finishes before exiting in tasks/sync