title: Why teardown_appcontext required to close db connection?
body: <p>According to <a href="http://flask.pocoo.org/docs/0.11/tutorial/dbcon/#step-3-database-connections" rel="nofollow noreferrer">flask docs</a>, we should close the database connection when app context tears down:</p>
  
  <pre><code>def get_db():
      """Opens a new database connection if there is none yet for the
      current application context.
      """
      if not hasattr(g, 'sqlite_db'):
          g.sqlite_db = connect_db()
      return g.sqlite_db
  
  @app.teardown_appcontext
  def close_db(error):
      """Closes the database again at the end of the request."""
      if hasattr(g, 'sqlite_db'):
          g.sqlite_db.close()
  </code></pre>
  
  <p>But wouldn't the tearing down of the app context remove the (only) reference to the database connection (as <code>g.sqlite_db</code> disappears when <code>g</code> disappears)? I thought that would automatically close the connection (since db driver would <a href="http://initd.org/psycopg/docs/connection.html#connection.close" rel="nofollow noreferrer">close the connection on <code>del</code></a>). What's the benefit of the explicit closing of the connection?</p>