title: How to exit a route in express.js?
body: <p>Right know i wrap it whole in a big if else statement because i have multiple res.render functions.</p>
  
  <p>How can i do something like this, which should prevent the rest of the route to be executed:</p>
  
  <pre><code>if(req.params.url === undefined){
      res.render('layout');
      return;
  }
  </code></pre>
  
  <p>OR:</p>
  
  <pre><code>if(req.params.url === undefined){
      res.render('layout');
      next();
  }
  </code></pre>
  
  <p>But both of the execute the rest of the code below them, which cause Headers already sent.</p>
  
  <p>Right now my code looks like this:</p>
  
  <pre><code>exports.activate = function(req, res){
      var hash = req.params.hash;
  
      if(hash === undefined){
          res.render('activation');
          next();
      } else {
             // Do stuff with hash
             res.render('activateOne', {hash: hash});
      }
  
  }
  </code></pre>