This is a happy ending not a sad ending. I don't know why some people keep being convinced that this is a dream or an after life vision.

Xiao Heng survived because he killed their ruler

In The Art Of War morals laws are important. Obeying  the ruler to death  is a must.
On the battlefields, the person that counts is the ruler. Once the ruler is dead, the army surrenders or retreats.

See The art of war University of toledo :
https://www.utoledo.edu/rotc/pdfs/the_art_of_war.pdf

-  The battle is won by the ruler . When the ruler is dead the army retreats:

"Terrain :
11. If the enemy has occupied them before you, do not follow him, but retreat and try to entice him away.
[The turning point of Li Shih-min's campaign in 621 A.D. against the two rebels, Tou Chien-te, King of Hsia,and Wang Shih-ch`ung, Prince of Cheng, was his seizure of the heights of Wu-lao, in spike of which TouChien-te persisted in his attempt to relieve his ally in Lo-yang, was defeated and taken prisoner. See CHIUT`ANG, ch. 2, fol. 5 verso, and also ch. 54.

- Morals laws are important. A soldier must obey the leader. This is why if the leader looses  as shown above with the prince and the king. The soldiers surrender or retreat ( regardless of their number).

" 3. The art of war, then, is governed by five constant factors, to be taken into account in one's deliberations,when seeking to determine the conditions obtaining in the field.
4. These are:
(1) The Moral Law; (2) Heaven; (3) Earth; (4) The Commander; (5) Method and discipline.

The MORAL LAW causes the people to be in complete accord with their ruler, so that they will follow him regardless of their lives, undismayed by any danger."

- If the ruler is exposed to insubordination, this ruler might commit suicide. ( see below). So soldiers must obey rules on the fields.

"14. Now an army is exposed to six several calamities, not arising from natural causes, but from faults for which the general is responsible. These are: (1) Flight; (2) insubordination; (3) collapse; (4) ruin; (5) disorganization; (6) rout.

[Tu Mu cites the unhappy case of T`ien Pu [HSIN T`ANG SHU, ch. 148], who was sent to Wei in 821 A.D. with orders to lead an army against Wang T`ing-ts`ou. But the whole time he was in command, his soldiers treated him with the utmost contempt, and openly flouted his authority by riding about the camp on donkeys, several thousands at a time. T`ien Pu was powerless to put a stop to this conduct, and when, after some months had passed, he made an attempt to engage the enemy, his troops turned tail and dispersed in every
direction. After that, the unfortunate man committed suicide by cutting his throat.] "

Conclusion : So  yes, Duke Su won the battle when he killed the ruler's enemy.
So the remaining soldiers either surrendered or retreated.
This is not a dream, he came back home to Xue Fang Fei. 

I hope this helps ^^

Without allies coming to rescue him, he would likely be captured and traded for benefits to the "defeated" Dai soldiers. 

I never thought of it this way or knew of this phenomenon or "code". 

I deduced my meaning of the ending by the flow of storytelling (death of JiJi and insurmantable enemy odds) as a slightly ambiguous sad ending and then the extra episode as a way to take it back and make it a happy ending to satisfy XueXiao fans. However, that SE seemed too abrupt and poorly handled as the screenwriters had been impeccable in handling the storytelling and adaptation, that even if it was a sad ending I found it hard to believe they would present it so poorly.

However, considering your point that once he killed the general the army would surrender (the rules they had followed earlier during the palace rebellion) it makes more sense.

The screenwriter wanted to convey the lost in battlefield and presumed dead that was the final plot of the novel: the hopelessness of waiting and surrealism of his return when there was no news for years. This explains why Wen Ji and Lu Ji had to die and why it looks like dreamscape.

Thank you, I think I finally get their intention. My faith in the production team is restored.

You are very much welcome ^__^

The era of depiction of the events is important and the millitary codes aswell.

 At a time when losing your honor could get you killed, I couldn't believe the narrative some viewers had  disregarding the ethic and codes making them believe that ordinary soldiers could take command and decide to kill an enemy when their ruler is dead on field. 

Soldiers obey orders they don't rebel or show insubordination. 

I felt compelled to make this point because a lot of people were fighting  over this topic.

This is my discussion about interesting points that i copied - pasted  here

There some tragic elements at the end of the drama that leans towards an open ending. So I understand why some people could think of it as such.
- The death of Wen Ji and Lu Ji,
- the men on horsebacks after the battle,
- the subjective camera when Xiao Heng gallops toward Xue Fang Fei .

Yes, I agree this is for easthetics . One could think about it as an open ending if we only consider these elements. However, as you stated, and I agree. Showing all that at the end of the drama adds a bittersweet taste to finish the show.
We could say that this leans toward an open ending because, as you said => it leave room for imagination.
This a manipulative strategy  writer / director use to add momentum at the  end of a movie.
Also, I totally agree with you: Bittersweet / sad ending are more memorable. So I get your point.

Yet, the subjective camera was used several time in the drama . So it does not add a meaning of bitterness or melancholy.
thus, when viewers understood this as a sad horseback scene I disagree.

If it was my choice.
The director could have let Xiao Heng reach Xue Fang fei under the tree.
But he did not. So=> room for imagination. I get it.

Nobody can change how viewers feel. I explained the logic of events as they occurred in an historical context. This set the basis of the
characters behaviour.
 I cannot discuss viewers taste for open endings. This undeniable.
I am going to copy past this on the discussion above, because yu opened my views on this topic, thank you.