title: Properly terminate NodeJS Async Await
body: <p>I wrote the following code to connect to MongoDB wrapped in a Promise, but as soon as it is connected, my NodeJS code is still running / not exit properly. May I know what is the proper way to return or terminate it? </p>
  
  <pre><code>function connectDB() {
    return new Promise (resolve =&gt; {
      MongoClient.connect(mongoUrl, function( err, db ) {
        _db = db;
        resolve(db);
      });
    })
  }
  
  
  (async function crawl() {
    const db = await connectDB(); 
    console.log('You are connected');
  })()
  </code></pre>