diff --git a/htdocs/install/etape2.php b/htdocs/install/etape2.php
index b8373847c2545d9b75633ea4afc6b1db619ad025..b4701481a879e986a5077bb04a029ac252fb836e 100644
--- a/htdocs/install/etape2.php
+++ b/htdocs/install/etape2.php
@@ -607,5 +607,5 @@ dolibarr_install_syslog("--- install/etape2.php end", LOG_INFO);
 
 pFooter(!$ok,$setuplang);
 
-$db->close();
+if (isset($db) && is_object($db)) $db->close();
 ?>
\ No newline at end of file