shukra —
Add the Browser object and then use Browser->On Back button to detect when the devices back button is pressed.
On back button
Triggered when the user presses the device's 'Back' button. Note not all devices have this button (e.g. iOS devices only have a 'Home' button) and not all platforms support this trigger.
Detecting when on the first page or other page you could do using a System->Compare two values with one being the in-built value LayerName, if you don't have separate Event Sheets for the menu and levels.
You could use a Global variable to track the last layout (that is, before you load a layout, set the Global variable to the current layout name), and use System->Go to layout to load it.
You might be able to use Browser->Close to exit the app