Metro-style apps are very similar to Windows Phone apps. They have a similar application model (for example they can be suspended, and when suspended they can be killed by the operating system if memory is needed), so they need to maintain state. Also, and that is the topic of this post, they cannot be ended by the user in a “normal” way, i.e. there is no File / Exit menu and no “X” button in the corner. Once started, the application remains in memory until the following happens:
- The app is in suspended mode (not in the foreground) and the system needs to reclaim the RAM.
- The advanced user starts the Task manager, locates the application and kills the process.
Note: Unfortunately I cannot illustrate this with a picture, because my Task Manager refuses to run more than 2 seconds for some unknown reason. Windows 8 is a preview release (TM).
However sometimes you need to kill a Metro style app, because Visual Studio will refuse to start a second instance if the first one is still running. You will get an error message like the following:
So should you use the task manager?
Well thankfully you don’t have to use the task manager (which is a blessing since, as I mentioned, mine keeps crashing all the time). Instead, just navigate to the application in question with Alt-Tab, and then press Alt-F4. This is a quick and easy way to euthanize your app and start a fresh new one in Studio later.
Of course, pressing Alt-F4 requires you to have a real keyboard, since the on screen keyboard does not have any function key (nor the Alt key for that matter). But honestly, who writes code without a real keyboard anyway (I mean, except me when I am in bed and REALLY REALLY want to try something out).