Question About A Theoretical Situation

It's my first time posting here, and I'm not so sure whether I'm asking right, but regardless...I had a thought about how I could implement special situations in my game, such as:

1. Auto-closing the game without crashing.

2. Changing a variable and having it stay there before the game closes, so that the variable remains the same when run again and not reset to a default.

I'm not exactly sure how to go about doing this, and I would hope I could accomplish this without crashing the game or having to do a overly long workaround.
I think there is a language barrier here, because I don't know what you mean by "autoclose without crashing" - if a game crashes with an error when trying to close it, then there is something wrong with the game.

In your second question I think you're writing about persistant variables - variables that stay the same no matter what game is loaded or started.
If that assumption is correct, then the solution is a plugin like http://himeworks.com/2015/12/sync-save-data/
(there are similiar plugins from other scripters like yanfly)
Can't you just use the force quit/return to menu (I can't remember what it is actually called) event command? I think @Andar's should work fine for the variables, I can't think of a way to do it without scripts.
The first question, I think, was about how to have the game close the entire game window when something happens, without the player's input. The second one, I'm not 100% sure but I think it was about how to set variables without saving, which Hime's plugin is not designed for (in which case I would recommend writing to a Global File in the game folder). Both of these requests seem to be inspired by Undertale.

Anyway, you will need plugins (or at least a few lines of JavaScript) to do either one of these. Learning JS would be the best place to post for the first one; Plugin Requests for the second one if Hime's won't work for you.
I think there is a language barrier here, because I don't know what you mean by "autoclose without crashing" - if a game crashes with an error when trying to close it, then there is something wrong with the game.

I really don't know how else to describe it. I want the game to close without an error message saying that it crashed.
@PsionicBurst I think the confusion with your request is that, under normal circumstances, it *already* doesn't show an error message. So that makes it confusing because now one has to wonder "Well, what did you do that made it SHOW an error message? That's not normal." Have you already tried something and got an error message, or are you just assuming that you'd get one?
1. Auto-closing the game without crashing.
I think he means he wants to implement an event that quits the game back to Windows. Not an option in the menu to quit (there's a plug-in for that), but an in-game event that closes the game. Am I right?

2. Changing a variable and having it stay there before the game closes, so that the variable remains the same when run again and not reset to a default.
I don't exactly know what do you mean with this, but variables are saved when you save a game. But maybe if you want to save a variable without having to save the game, maybe it could use an external file. I don't know if MV could make use of INI files or something similar to save that kind of settings, though. Probably JSON?
Yes. Correct for both of them. I'm not so sure on how to implement INI within the settings however.

Edit: Figured out how to do that first one using a small script "window.close()", but I'm still hung on the second one.

Original thread: https://forums.rpgmakerweb.com/threads/question-about-a-theoretical-situation.78137/