diff --git a/bin/dbus/dbusclient.cpp b/bin/dbus/dbusclient.cpp
index c7038b9ed8a03d00c344e1899e94652190686d43..667a9c483f5530d03846841ccf291fd90d7ba56c 100644
--- a/bin/dbus/dbusclient.cpp
+++ b/bin/dbus/dbusclient.cpp
@@ -23,13 +23,9 @@
 #include "config.h"
 #endif // HAVE_CONFIG_H
 
-#include <cstdlib>
-#include <iostream>
-#include <cstring>
-#include <stdexcept>
-
 #include "dbusclient.h"
 #include "dbus_cpp.h"
+#include "dring.h"
 
 #include "dbusinstance.h"
 
@@ -49,6 +45,11 @@
 #include "videomanager_interface.h"
 #endif
 
+#include <iostream>
+#include <stdexcept>
+#include <cstdlib>
+#include <cstring>
+
 class EventCallback :
     public DBus::Callback_Base<void, DBus::DefaultTimeout&>
 {
@@ -102,7 +103,7 @@ DBusClient::~DBusClient()
 {
     // instances destruction order is important
     // so we enforce it here
-
+    DRing::unregisterSignalHandlers();
 #ifdef ENABLE_VIDEO
     videoManager_.reset();
 #endif
@@ -220,13 +221,13 @@ DBusClient::initLibrary(int flags)
     if (!DRing::init(static_cast<DRing::InitFlag>(flags)))
         return -1;
 
-    registerSignalHandlers(callEvHandlers);
-    registerSignalHandlers(configEvHandlers);
-    registerSignalHandlers(presEvHandlers);
-    registerSignalHandlers(audioEvHandlers);
-    registerSignalHandlers(dataXferEvHandlers);
+    DRing::registerSignalHandlers(callEvHandlers);
+    DRing::registerSignalHandlers(configEvHandlers);
+    DRing::registerSignalHandlers(presEvHandlers);
+    DRing::registerSignalHandlers(audioEvHandlers);
+    DRing::registerSignalHandlers(dataXferEvHandlers);
 #ifdef ENABLE_VIDEO
-    registerSignalHandlers(videoEvHandlers);
+    DRing::registerSignalHandlers(videoEvHandlers);
 #endif
 
     if (!DRing::start())
diff --git a/bin/dbus/dbusclient.h b/bin/dbus/dbusclient.h
index d7032c03bc26afe9be38255d08ea15950d8476b6..c4910bf5aa4dea5e8e0ccdc2973e67427198b069 100644
--- a/bin/dbus/dbusclient.h
+++ b/bin/dbus/dbusclient.h
@@ -26,7 +26,6 @@
 #endif // HAVE_CONFIG_H
 
 #include "dring/def.h"
-#include "dring.h"
 #include <memory>
 
 class DBusConfigurationManager;
diff --git a/bin/main.cpp b/bin/main.cpp
index 81b7efb6c375c814023470a5f543356c862b9a98..22d0535fffa005e1257e896128f64cfb1d815db8 100644
--- a/bin/main.cpp
+++ b/bin/main.cpp
@@ -21,13 +21,6 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
  */
 
-#include <iostream>
-#include <thread>
-#include <cstring>
-#include <signal.h>
-#include <getopt.h>
-#include <cstdlib>
-
 #include "dring/dring.h"
 
 #include "logger.h"
@@ -40,13 +33,22 @@
 
 #include "fileutils.h"
 
+#include <signal.h>
+#include <getopt.h>
+
+#include <iostream>
+#include <thread>
+#include <memory>
+#include <cstring>
+#include <cstdlib>
+
 static int ringFlags = 0;
 static int port = 8080;
 
 #if REST_API
-    static std::unique_ptr<RestClient> restClient;
+static std::weak_ptr<RestClient> weakClient;
 #else
-    static std::unique_ptr<DBusClient> dbusClient;
+static std::weak_ptr<DBusClient> weakClient;
 #endif
 
 static void
@@ -88,14 +90,14 @@ parse_args(int argc, char *argv[], bool& persistent)
 
     const struct option long_options[] = {
         /* These options set a flag. */
-        {"debug", no_argument, NULL, 'd'},
-        {"console", no_argument, NULL, 'c'},
-        {"persistent", no_argument, NULL, 'p'},
-        {"help", no_argument, NULL, 'h'},
-        {"version", no_argument, NULL, 'v'},
-        {"auto-answer", no_argument, &autoAnswer, true},
-        {"port", optional_argument, NULL, 'x'},
-        {0, 0, 0, 0} /* Sentinel */
+        {"debug",       no_argument,        nullptr,    'd'},
+        {"console",     no_argument,        nullptr,    'c'},
+        {"persistent",  no_argument,        nullptr,    'p'},
+        {"help",        no_argument,        nullptr,    'h'},
+        {"version",     no_argument,        nullptr,    'v'},
+        {"auto-answer", no_argument,        &autoAnswer, true},
+        {"port",        optional_argument,  nullptr,    'x'},
+        {nullptr,       0,                  nullptr,     0} /* Sentinel */
     };
 
     while (true) {
@@ -173,13 +175,8 @@ signal_handler(int code)
     signal(SIGTERM, SIG_DFL);
 
     // Interrupt the process
-#if REST_API
-    if (restClient)
-        restClient->exit();
-#else
-    if (dbusClient)
-        dbusClient->exit();
-#endif
+    if (auto client = weakClient.lock())
+        client->exit();
 }
 
 int
@@ -211,31 +208,18 @@ main(int argc, char *argv [])
     signal(SIGTERM, signal_handler);
     signal(SIGPIPE, SIG_IGN);
 
-#if REST_API
     try {
-        restClient.reset(new RestClient {port, ringFlags, persistent});
-    } catch (const std::exception& ex) {
-        std::cerr << "One does not simply initialize the rest client: " << ex.what() << std::endl;
-        return 1;
-    }
-
-    if (restClient)
-        return restClient->event_loop();
-    else
-        return 1;
+#if REST_API
+        if (auto client = std::make_shared<RestClient>(port, ringFlags, persistent))
 #else
-    // initialize client/library
-    try {
-        dbusClient.reset(new DBusClient {ringFlags, persistent});
+        if (auto client = std::make_shared<DBusClient>(ringFlags, persistent))
+#endif
+        {
+            weakClient = client;
+            return client->event_loop();
+        }
     } catch (const std::exception& ex) {
-        std::cerr << "One does not simply initialize the DBus client: " << ex.what() << std::endl;
-        return 1;
+        std::cerr << "One does not simply initialize the client: " << ex.what() << std::endl;
     }
-
-    if (dbusClient)
-        return dbusClient->event_loop();
-    else
-        return 1;
-#endif
-
+    return 1;
 }
diff --git a/src/client/ring_signal.cpp b/src/client/ring_signal.cpp
index e60d5460f5441dad02bfb77eaaf074c08ecc5b59..57d7ab2614a2fb98234f534409d425942bce5a3b 100644
--- a/src/client/ring_signal.cpp
+++ b/src/client/ring_signal.cpp
@@ -139,4 +139,14 @@ registerSignalHandlers(const std::map<std::string,
     }
 }
 
+void
+unregisterSignalHandlers()
+{
+    auto& handlers_ = jami::getSignalHandlers();
+    for (auto& item : handlers_) {
+        item.second = {};
+    }
+}
+
+
 }
diff --git a/src/dring/dring.h b/src/dring/dring.h
index cc83f505e6dbaf88c35a0f6ad3a51282d87297c3..3a95a6020f3532a5a814852f71149bb057cf9c0f 100644
--- a/src/dring/dring.h
+++ b/src/dring/dring.h
@@ -145,6 +145,7 @@ exportable_callback(std::function<typename Ts::cb_type>&& func) {
 }
 
 DRING_PUBLIC void registerSignalHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&);
+DRING_PUBLIC void unregisterSignalHandlers();
 
 } // namespace DRing