Moved destruct to the end of file
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index c757277..44c864e 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -90,13 +90,6 @@
 		log_message('debug', 'Database Driver Class Initialized');
 	}
 
-	// --------------------------------------------------------------------
-
-	public function __destruct()
-	{
-		$this->close();
-	}
-
 	// --------------------------------------------------------------------	
 
 	/**
@@ -1397,6 +1390,23 @@
 	{
 	}
 
+	// --------------------------------------------------------------------
+
+	/**
+	 * Destructor
+	 *
+	 * Closes the database connection, if needed.
+	 *
+	 * @return	void
+	 */
+	public function __destruct()
+	{
+		if ($this->conn_id && ! $this->pconnect)
+		{
+			$this->close();
+		}
+	}
+
 }
 
 /* End of file DB_driver.php */