Custom Remove/Leave Effect for Yanfly's Buffs & States Core

I am trying to make a skill that forces an actor to use a skill on an enemy/ies when the state's turn counter becomes 0 (it ends, in essence) or it is removed manually. I'm using the following code to accomplish this:

<Custom Remove Effect>
$gameParty.members()[0].forceAction(47)
</Custom Remove Effect>

The problem is, when the state ends, there is no effect. It works fine if I get rid of it manually, however. It even works when I use 'addState(x)' instead of 'forceAction'. Why does forceAction not work with this?

EDIT: I think I managed to resolve it by adding the following line of code:

<Custom Remove Effect>
$gameParty.members()[0].forceAction(47);
BattleManager.forceAction($gameParty.members()[0])
</Custom Remove Effect>

I'm not sure why it was necessary, but it worked.
There was a similar query just recently I think. It looks like you've solved it already, but just in case you want a more in depth look, Yanfly did a Tips and Tricks post on this sort of thing:
http://yanfly.moe/2016/06/04/tips-tricks-cagnazzos-tsunami-final-fantasy-4-rpg-maker-mv/#more-3039

Original thread: https://forums.rpgmakerweb.com/threads/custom-remove-leave-effect-for-yanflys-buffs-states-core.83130/