k6aks I would say it still looks very complicated as for code managing scene changes. Why using while loop in _unhandled_key_input() method? _unhandled_key_input() is called every time user press key and that key press is not handled by anything else (like for example textbox which may "consume" key press when user is typing something into it), so just need to take action based on received event. If it is not even you are expecting, just do nothing. Currently it seems like active waiting what is very bad pattern in programming, because it may unnecessarily use resources.
If you want to make stats menu, help menu and quit only accessible from main menu, and main menu accessible from game why not just have code related with handling that contained in relevant scenes?
I mean like:
- MainMenuScene -> have script attached handling StatsMenu, HelpMenu, Quit and Play
- Game -> have script attached handling go back to MainMenuScene
That way in game you will be only able go back to MainMenu and in MainMenu you will be able to do all other things you want (stats, help, quit, play). Also code will be contained in scenes it belongs to what is also good, because then if you see issue in MainMenu you know code which may cause issue is probably also in MainMenu scene.
What I am trying to say is you need to make it more modular I think. If you are just learning it may be not so easy and obvious how to do it, but the bigger your project will grow the harder it will be to maintain such monolithic code.