Immediately after the last Baddie is defeated.

There may be special victory circumstances on an Encounter Card that differ from this, but generally a Battle ends as soon as the last Baddie falls. When fighting Tyrants, the Battle ends as soon as the Tyrant is defeated, even if Baddies remain.