Trump wants a way out of a war that has badly hit the US economy less than six months before midterm elections, which will decide if his Republican party keeps control of Congress.