Prior to this, he just expected to... win the elections. The Midterms, the illegal 3rd term he intends to run for - he just assumed he'd win.
Now he realizes he won't. Attacking Iran was not a magic I win button after all, and he doesn't have any ideas left.
But he has Stephen Miller. And Stephen Miller knows a way to retain power even if you can't win elections.
And thus - everything that's happened the past three weeks or so.