title: How can I exit a batch file from within a function?
body: <p>I have a simple function written to check for directories:</p>
  
  <pre><code>:direxist
  if not exist %~1 (
      echo %~1 could not be found, check to make sure your location is correct.
      goto:end
      ) else (
      echo %~1 is a real directory
      goto:eof
      )
  </code></pre>
  
  <p>:end is written as </p>
  
  <pre><code>:end
  endlocal
  </code></pre>
  
  <p>I don't understand why the program would not stop after goto:end has been called. I have another function that uses the same method to stop the program and it work fine.</p>
  
  <pre><code>:PRINT_USAGE
  echo Usage:
  echo ------
  echo &lt;file usage information&gt;
  goto:end
  </code></pre>
  
  <p>In this instance, the program is stopped after calling :end; why would this not work in :direxist? Thank you for your help!</p>