So you need to keep track of what state the game is in e.g. title screen, game screen, exit screen then you can respond to the controls in different ways depending what the state is. There is a simple example in this post https://fuzearena.com/forum/topic/852/exit-the-game-loop-back-to-title-screen/2?_=1683130244723