Managing Message Timing With Battle Animations

I have a function with these two lines of code (it occurs during battle):


target.die();
$gameMessage.add("Test");


They both work properly, except for one thing: the message appears before the death animation even starts. How would I make sure that the message only appears after the enemy has finished their death animation and disappeared from the battle scene?
Make boss immortal, check if their hp <= 0. Make an invi enemy appear, Remove boss immortality, and then do stuff then kill that invi enemy off event wise.
Ah, thanks. I ended up doing it a different way. After calling target.die() I set a variable for the target to true. I aliased the Game_Enemy.prototype.performCollapse, call the original function and then checked if the variable was true, and then added the game message. That way the message only appears after the collapse animation.

Original thread: https://forums.rpgmakerweb.com/threads/managing-message-timing-with-battle-animations.56028/