The midterm results laid bare the deep unpopularity of the war of choice that President Trump started and is now struggling to end.