title: How to stop mongodb server on Windows?
body: <p>I'm using the nginx/PHP/MongoDB stack and trying to set up my development environment on Windows by creating two batch files.</p>
  
  <p>start.bat</p>
  
  <pre><code>cd C:\www\nginx
  start nginx
  cd C:\www\php
  start php-cgi.exe -b 127.0.0.1:9000
  cd C:\www\mongodb
  start mongod
  </code></pre>
  
  <p>stop.bat</p>
  
  <pre><code>cd C:\www\nginx
  nginx -s quit
  cd C:\www\php
  taskkill /F /IM php-cgi.exe
  cd C:\www\mongodb
  mongo --eval "use admin; db.shutdownServer(); quit"  # this doesn't work
  mongo --eval stop_mongod.js  # this doesn't work either
  </code></pre>
  
  <p>Using taskkill to stop mongod isn't an option, since that may lead to data corruption.
  Any suggestions?</p>