Clear All Common Events?

Hello again. Back from the dead to ask a question. It's a bit of a weird situation so bear with me here:

I'm making a game that's entirely run via common events, with very little player control outside of choices/text/menu processing. There are two issues i'm facing right now because of this:
#1 are game overs. Since i'm using a game over common event plugin, the game won't end if all actors are defeated until all other common events finish processing, which leads me to issue #2: Since all these common events keep piling up in reserve, it'll probably cause issues if there's too many at a time. So my question: Is there a way to completely remove all currently processing common events at once, and - say, leave an autorun event on the map that opens a menu if there's nothing else running at the moment?

Apologies if this was asked before. I've been searching around and found nothing so far
the best way if it's using a switch, turn off the switch, you can batch
all switches when needed in 1 sweep.

but you cannot simply "remove" common events.
based on the underlying code for what it looks like to add/activate a common event, I'd assume you could probably do something like:

JavaScript:
$gameMap._commonEvents = [];
$gameTemp.clearCommonEvent();

That would presumably purge the events that have been setup for the current map, and stop the currently-running event.

Of course, this is theory, I didn't test this at all, I just dug through the MV base code looking for "commonevent" and these are the things I found.
Since all these common events keep piling up in reserve,
they key tto that is how you're handling events.

there are theoretically two different ways to start a common event: either by calling it as a subroutine (in which case it needs to be completed to end) or as a triggered autorun/parallel (in which case the trigger needs to beswitched off).

From your post I assume you're recursively calling the common events by themselves again and again. That has a lot more problems than just requiring more and more RAM, and if you're doing that you should restructure your logic. Because that will crash on your players sooner or later.
Most of the gameplay is handled by a single CE that loops for a set amount of times and calls other CEs when appropriate, all of which finish on their own normally. Afterwards, the player is taken to a menu. I just need to ensure the CE list is as cleared up as possible before another gameplay loop takes place without simply returning to the map and giving control to the player, which is unnecessary .

My issue with utilizing switches is how priority is handled. Most of these other events (that are meant for calculations) happen in the middle of CEs and I can't simply turn them on and off since the CEs calling them would start from the beginning.

EDIT: Alright, I addressed it by leaving an autorun event with pages opening different custom menus depending on a switch. The other issue is much tougher for me. I'd rather not have a game over scene that force players to reload a save. just a single animation and then back to a custom menu. However, once the animation finishes, the rest of the CE plays out as if nothing happened. The clearCommonEvent(); function didn't work.

Original thread: https://forums.rpgmakerweb.com/threads/clear-all-common-events.136667/