I tried to make aplkasi game, but there is little less that how to exit game application by pressing back button and pop up option exit yes no. The script I created is standard like this.
Develop games in your browser. Powerful, performant & highly capable.
You can use a Dialog plugin in order to create a pop-up box to give the user an option to exit the game when the back button is pressed.
There's two dialog plugins that i've used, both work well.
There might be other dialog plugins, but these are the ones i've used so i can vouch for them.
Hope that helps.