title: Close Android app Jquery - Phonegap
body: <p>I'm trying to close my Phonegap Android app with the following piece of code:</p>
  
  <pre><code>document.addEventListener("backbutton", function () { 
      if ($('.screenshot').is(":visible")) {
          if (confirm('Afsluiten?')){
              setTimeout( function() { navigator.app.exitApp(); });
          }
          else {
              '';
          }
      }
      else {
          $(".items , .screenshot").show();
          $(".content , .openbrowser , .html5vid , .introtekst_gal" ).hide();
          $(".terug").hide();
      }
  }, true);
  </code></pre>
  
  <p>It works once: Pressing the back-button and then "Ok" closes the app, as expected.</p>
  
  <p>But when I do it like this, the app doesn't close anymore:</p>
  
  <ul>
  <li>Press back-button (pop up shows)</li>
  <li>Press "cancel" (pop up goes away)</li>
  <li>Press back-button (pop up shows)</li>
  <li>Press "ok" (pop up goes away and app SHOULD close, but doesn't)</li>
  </ul>
  
  <p>What am I doing wrong?</p>