Since I had 5 non hostile enemies at the end of the defence mission, I got the "defend accomplished" message before I had killed the last 5 hostile enemies. The GUMID's made sure of that. Once I had killed the 5 non hostiles, I talked to the Mayor, took over the city and placed 25 militias in the town. I've found that you need atleast 25 if you wanna have a good chance of defending a captured town.
In your case I would fail the mission and keep playing, the cash you got from the dead enemies is more than enough compensation

And you can atleast continue your campaign, it's not a game stopper anymore. But if you really want a successful mission I suspect you need to fight the battle again and hope you'll get the "defend accomplished" message before the end of the battle.
The good news is that I think I found the reason for the GUMID error, or at least I hope I have. Since I'm snowed in and wont have to go to work until next week I'll have time to test and see if it's fixed.