Index: trunk/src/sh_prelude.c
===================================================================
--- trunk/src/sh_prelude.c	(revision 107)
+++ trunk/src/sh_prelude.c	(revision 108)
@@ -79,5 +79,5 @@
  * includes for samhain-specific functions (sl_strstr, sh_error_handle)
  */
-#include "slib.h"
+#include "samhain.h"
 #include "sh_cat.h"
 #include "sh_error_min.h"
@@ -984,6 +984,14 @@
         if (initialized < 1)
                 return;
-        prelude_client_destroy(client, PRELUDE_CLIENT_EXIT_STATUS_SUCCESS);
+
+	if (sh.flag.isdaemon == S_TRUE)
+	        prelude_client_destroy(client, PRELUDE_CLIENT_EXIT_STATUS_FAILURE);
+	else
+	        prelude_client_destroy(client, PRELUDE_CLIENT_EXIT_STATUS_SUCCESS);
+
 	client = NULL;
+
+	prelude_deinit();
+
         initialized = 0;
         return;
