title: Properly shutting down MongoDB database connection from C# 2.1 driver?
body: <p>I am just getting started with integrating MongoDB into my application and I have ran into a few questions. In my application I am using the newest 2.1 version of the MongoDB C# driver and only using MongoDB for application logging.</p>
  
  <p>Currently before showing my main application <code>Form</code> I first check to see if <code>mongod.exe</code> is running and if not I start it. Then when my main <code>Form</code> is shown it opens a connection to the database for use seen below.</p>
  
  <pre><code>public void Open()
  {
      Client = new MongoClient("mongodb://localhost:27017");
      Database = Client.GetDatabase(DBName);
      Collection = Database.GetCollection&lt;BsonDocument&gt;(ColName);
  }
  </code></pre>
  
  <p>My question is how I should properly shutdown this connection when my application is closing? </p>
  
  <p>Also are there in considerations I should take into account in leaving <code>mongod.exe</code> running versus exiting it each time the application closes?</p>
  
  <p>I have searched a few times trying to figure out if there is a proper way to shutdown the connection but have found nothing very specific. There is an old SO post (that I can't seem to find now) mentioning a <code>.Dispose</code> method, though I cannot seem to find it in the newest driver nor from my IDE's auto complete. </p>