Actually close the database handle when the db_lock is completed