This example helped me to do something similar in my TideSDK app: https://gist.github.com/MisterPoppet/4639473
Pulling from the example there you may be able to do something like below to accomplish what you are asking:
var appWindow = Ti.UI.getCurrentWindow();
appWindow.addEventListener(Ti.CLOSE, function(event) {
var r = confirm("Do you want to exit the application?");
if (r == true) {
//close
} else {
//cancel close
event.preventDefault();
return false;
}
});