title: Unclean shutdown with MongoDB results in corrupted mongod.lock file
body: <p>I have a MongoDB database storing data in a particular directory, and I am using a Node.js process to write to it. Sometimes my Node.js process experiences a forced shutdown (notice the passive voice) and I get this error message, which pretty much means I have to go in and simply delete the .lock file:</p>
  
  <pre><code>2015-06-16T11:09:19.004-0700 W -        [initandlisten] Detected unclean shutdown - /Users/amills001c/mongodb_sc_admin_dev_data/mongod.lock is not empty.
  2015-06-16T11:09:19.013-0700 I STORAGE  [initandlisten] **************
  old lock file: /Users/amills001c/mongodb_sc_admin_dev_data/mongod.lock.  probably means unclean shutdown,
  but there are no journal files to recover.
  this is likely human error or filesystem corruption.
  </code></pre>
  
  <p>What is the best way to prevent this from happening so I don't have to go in and delete the mongod.lock file everytime I start up the database?</p>
  
  <p>Something like this?</p>
  
  <pre><code>   process.on('SIGINT', function (msg1,msg2) {
          mongoose.disconnect();
          mongoose.connection.close(function (msg) {
              console.log(msg);
          });
          console.log('SIGINT message:',msg1,msg2)
      });
  </code></pre>