Pre-terminate for JS

In VXAce, there's a part where when you do a Scene and terminate it, there's the pre_terminate function that allows you to do something before termination. For example, I want to change the location of my menu before I terminate it, but then I can't do that because when I press cancel, it terminates it right away. Is there a way in JavaScript to recreate the pre_terminate function?
This was all there is to Ace

Code:
class Scene_Base  def main    start    post_start    update until scene_changing?    pre_terminate    terminate  endend
So what you could do is just call pre-terminate inside terminate
Code:
Scene_Base.prototype.terminate = function() {  // pre-terminate ?  // then normal terminate processing};
I tried doing this at first but it terminates it quickly. I'll have to reconsider my code, it could have been my mistake. Thanks a lot.
Scene_Base.prototype.stop is called first and the next scene waits until Scene_Base.prototype.isBusy returns false, before calling terminate. So, you can start your animation during "stop" and wait, until it's finished before returning false in "isBusy".
That is helpful. I will try this now and see how it works.

Original thread: https://forums.rpgmakerweb.com/threads/pre-terminate-for-js.54891/