Move closing of database connection to CI_DB_driver->__destruct - #1376
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index 00db6e1..585bb7b 100755
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -393,15 +393,5 @@
  */
 	$EXT->call_hook('post_system');
 
-/*
- * ------------------------------------------------------
- *  Close the DB connection if one exists
- * ------------------------------------------------------
- */
-	if (class_exists('CI_DB') && isset($CI->db) && ! $CI->db->pconnect)
-	{
-		$CI->db->close();
-	}
-
 /* End of file CodeIgniter.php */
 /* Location: ./system/core/CodeIgniter.php */
\ No newline at end of file
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index ef77b59..c757277 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -92,6 +92,13 @@
 
 	// --------------------------------------------------------------------
 
+	public function __destruct()
+	{
+		$this->close();
+	}
+
+	// --------------------------------------------------------------------	
+
 	/**
 	 * Initialize Database Settings
 	 *