What do I do with stacked units when city is at war?

Solution 1:

According to this thread it's possible in Civ 5 to change production to something else without losing the previous unit / building. Unfortunately while I do believe this should work I haven't played Brave New World and I've been playing Civ 4 and Civ 6 as well as 5 so I may be confusing which version it's possible in or this may have been changed.

Anyway, it should be possible to change your production to something else (preferably another wonder or an expensive unit or building) and speed the completion of that with your great engineer before switching back to the original wonder and letting it's construction finish naturally.

Solution 2:

You could:

  1. Rush Wonder. It may seem like a waste, but you can always rush engineer generation afterwards.

  2. Soothe things over. Have you tried asking for peace with the enemy? It may be a high cost, but you can always trade off a smaller city and get it back later after building up an army.

Personally I'd try option 2 first. If they are unwilling to accept a peace treaty then option 1 is really your only viable option.