How can I close windows phone 8 app developed using html5.

I have tried javascript to do so my writting a block of code like below

$(document).ready(function(e) {      
    $("#exitButton").click(function(e){   
        alert("App Closing now..");
        //window.navigate.app.exitApp();
        window.navigator.app.exitApp();
    });
 });

which is not working in my case.

Help me on how to close my HTML5 application?