Call when terminating a script. Closes the database to be sure that we do not build up outstanding connections