Do a conditional branch with
$gameTroop.aliveMembers().length === 0
doesn't matter, because the second the last enemy is dead, the engine ends the battle even before processing any troop event. So your troop event wouldn't run anyway.
Please take two steps back and explain to us what you really want to do. Then we might be able to explain a workaround to you.
there are several different workarounds with different advantages and disadvantages, so we need nmore info to guess which way would be best to use here.
Oh, good point Andar.
Yeah, best to tell us what you're trying to do.
As Andar said, the moment the last enemy dies the battle ends and your troop event won't be running any more, so it'll never hit that code.
instead of trying to force the HUD off, how about you try to bughunt it to find out why it doesn't go off automatically?
Because that seems to be the problem, and you need to solve problems in bughunting, not hide them behind overrides - because the bug might do more than just keep the HUD when it should go off.