Close db connection at the end so that script exits cleanly