Help to turn off Yanfly's Trance state

Hi, all!
I'm using this http://yanfly.moe/2016/08/24/tips-tricks-trance-final-fantasy-9-rpg-maker-mv/ for trance state.
It works really well, except I want to turn it off after battle end.
I tried checking the "remove at battle end" box, but didn't solve the problem.
So, I think I have to make a common event that works in parallel if party have certain state on, it would be removed. The problem is, the event must be triggered by a switch.
Is it possible to turn on a switch from inside a state?
Please help me.
My guess is that inside the Lunatic Code where you are setting user._trance = true, you could also directly set a Switch using:
$gameSwitches.setValue(15, true)
(Replace 15 with the Switch # you want to use in your Parallel Event, and MAKE SURE you set that Switch OFF at the end of the Event).

If that doesn't work for some reason, you could always simply turn the Switch ON at the beginning of each battle using a Troop Event (Turn 0, Timing: Battle) instead. This will force the Parallel Event to run once at the end of every battle and you can use it to remove the Trance from every character. Again, make sure you turn the Switch OFF at the end of the Event.
Thank you for fast response, I'll try it out. But, I'm just casual maker, not a lunatic(expert), so I can only copy paste or do a little adjustment.. where should I put $gameSwitches.setValue(15, true) in these:
<Custom Passive Condition>

// Check if the party is in battle.

if ($gameParty.inBattle()) {

// Default the user's trance state to false.

user._trance = user._trance || false;

// Sets the condition for the user to be either in the trance state or if the user's TP matches the user's MaxTP.

condition = user._trance || user.tp === user.maxTp();

} else {

// Otherwise, the condition is false.

condition = false;

}

// If the condition passes...

if (condition) {

// And if the user isn't in the trance state...

if (!user._trance) {

// Then play an animation as the user enters trance.

user.startAnimation(130);

}

// Set the user's trance state to true.

user._trance = true;

}

</Custom Passive Condition>



<Custom Regenerate Effect>

// Set the TP drain amount.

var tp = 25;

// Reduce the user's TP.

user.gainTp(-tp);

// If the user's TP is 0...

if (user.tp === 0) {

// ...then turn off trance.

user._trance = false;

}

</Custom Regenerate Effect>

exactly? Is it too much if I ask a full lunatic code? Thank you in advance
Place it directly below user._trance = true; (it's about halfway through what you pasted, near the end of the Custom Passive Condition block) and make sure it's above the following } curly-bracket symbol.
To me this trick doesn't work.

In the common event I set that the TP go down to 0 and the status is removed.
Well, the status is not removed. TP drop to 0, but status is always there.
Tips?
BUMP!

Original thread: https://forums.rpgmakerweb.com/threads/help-to-turn-off-yanflys-trance-state.79542/