Disconnect the database handle cleanly on exit.