The ruling cited the shutdown’s damaging effects on American businesses and nonprofits.