Stop action after main target is dead?

is there a way to stop the remaining actions after the main target has been killed. i tried changing "this.aliveMembers()[0]" in line 4681 of rpg_objects to null so that the next actor to act won't target a random enemy however this isn't what i intended because the actor is still doing his attack animation.

Code:
Game_Unit.prototype.smoothTarget = function(index) {
    if (index < 0) {
        index = 0;
    }
    var member = this.members()[index];
    return (member && member.isAlive()) ? member : this.aliveMembers()[0];  <<-- this.aliveMembers()[0] to null
};

Edit: Nevermind got it!

Original thread: https://forums.rpgmakerweb.com/threads/stop-action-after-main-target-is-dead.94441/