Download Ceric's "Cannot Exit Screen" behaviour from StencylForge, and that will do the job for you.
If you have a look at the code in that behaviour, you will see how this kind of feature can be built. There's nothing wrong with using behaviours (in fact, it's good practice), but learning how other people's behaviours work is also a good idea, both from a learning point of view, and so that you can understand what's happening if things don't work as planned.