Index: trunk/ippTools/src/dettoolConfig.c
===================================================================
--- trunk/ippTools/src/dettoolConfig.c	(revision 7615)
+++ trunk/ippTools/src/dettoolConfig.c	(revision 7657)
@@ -18,5 +18,5 @@
     if (!config->modules) {
         psError(PS_ERR_UNKNOWN, false, "Can't find site configuration");
-        exit(EXIT_FAILURE);
+        goto FAIL;
     }
 
@@ -394,5 +394,5 @@
         psFree(rerunArgs);
 
-        exit(EXIT_FAILURE);
+        goto FAIL;
     }
 
@@ -423,5 +423,5 @@
         if (!psMetadataAddStr(config->where, PS_LIST_TAIL, #name, 0, "==", str)) {\
             psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
-            exit(EXIT_FAILURE); \
+            goto FAIL; \
         } \
     }
@@ -440,5 +440,5 @@
         if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "iteration", 0, "==", n)) {
             psError(PS_ERR_UNKNOWN, false, "failed to add item iteration");
-            exit(EXIT_FAILURE);
+            goto FAIL;
         }
     }
@@ -450,5 +450,5 @@
         if (!psMetadataAddStr(config->where, PS_LIST_TAIL, "camera", 0, "==", str)) {
             psError(PS_ERR_UNKNOWN, false, "failed to add item camera");
-            exit(EXIT_FAILURE);
+            goto FAIL;
         }
     }
@@ -458,5 +458,5 @@
         if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "imfiles", 0, "==", n)) {
             psError(PS_ERR_UNKNOWN, false, "failed to add item imfiles");
-            exit(EXIT_FAILURE);
+            goto FAIL;
         }
     }
@@ -467,5 +467,5 @@
         if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "p1_version", 0, "==", n)) {
             psError(PS_ERR_UNKNOWN, false, "failed to add item p1_version");
-            exit(EXIT_FAILURE);
+            goto FAIL;
         }
     }
@@ -473,5 +473,5 @@
         if (!psMetadataAddBool(config->where, PS_LIST_TAIL, "accept", 0, "==", boolean)) {
             psError(PS_ERR_UNKNOWN, false, "failed to add item accept");
-            exit(EXIT_FAILURE);
+            goto FAIL;
         }
     }
@@ -489,5 +489,5 @@
     if (!config->dbh) {
         psError(PS_ERR_UNKNOWN, false, "Can't configure database");
-        exit(EXIT_FAILURE);
+        goto FAIL;
     }
 
@@ -497,3 +497,7 @@
 
     return config;
+
+FAIL:
+    psLibFinalize();
+    exit(EXIT_FAILURE);
 }
