close db before deleting it