Make sure db is updatedt before script exits