Index: /trunk/ppStack/src/ppStack.c
===================================================================
--- /trunk/ppStack/src/ppStack.c	(revision 27107)
+++ /trunk/ppStack/src/ppStack.c	(revision 27108)
@@ -58,5 +58,5 @@
     // Common code for the death.
     {
-        psExit exitValue = ppStackExitCode(); // Exit code
+        psExit exitValue = ppStackExitCode(PS_EXIT_SUCCESS); // Exit code
 
         // Ensure everything closes
@@ -67,8 +67,6 @@
             ppStackFileActivation(config, PPSTACK_FILES_PHOT, true);
             if (!ppStackFilesIterateUp(config)) {
-                psErrorStackPrint(stderr, "Unable to close files.");
-                if (exitValue == PS_EXIT_SUCCESS) {
-                    exitValue = ppStackExitCode();
-                }
+                psError(psErrorCodeLast(), false, "Unable to close files.");
+                exitValue = ppStackExitCode(exitValue);
             }
         }
@@ -78,8 +76,6 @@
         psString dump = psMetadataLookupStr(&mdok, config->arguments, "DUMP_CONFIG"); // File for config
         if (dump && !pmConfigDump(config, dump)) {
-            psErrorStackPrint(stderr, "Unable to dump configuration.");
-            if (exitValue == PS_EXIT_SUCCESS) {
-                exitValue = ppStackExitCode();
-            }
+            psError(psErrorCodeLast(), false, "Unable to dump configuration.");
+            exitValue = ppStackExitCode(exitValue);
         }
 
@@ -93,4 +89,5 @@
         pmVisualClose();
 
+        exitValue = ppStackExitCode(exitValue);
         exit(exitValue);
     }
Index: /trunk/ppStack/src/ppStack.h
===================================================================
--- /trunk/ppStack/src/ppStack.h	(revision 27107)
+++ /trunk/ppStack/src/ppStack.h	(revision 27108)
@@ -170,5 +170,5 @@
 
 /// Return an appropriate exit code based on the error code
-psExit ppStackExitCode(void);
+psExit ppStackExitCode(psExit exitValue);
 
 #endif
Index: /trunk/ppStack/src/ppStackFinish.c
===================================================================
--- /trunk/ppStack/src/ppStackFinish.c	(revision 27107)
+++ /trunk/ppStack/src/ppStackFinish.c	(revision 27108)
@@ -94,7 +94,10 @@
 
 
-psExit ppStackExitCode(void)
+psExit ppStackExitCode(psExit exitValue)
 {
-    psExit exitValue = PS_EXIT_SUCCESS;        // Exit code to return
+    if (exitValue != PS_EXIT_SUCCESS) {
+        return exitValue;
+    }
+
     psErrorCode errorCode = psErrorCodeLast(); // Error code
     if (errorCode != PS_ERR_NONE) {
