diff --git a/src/dht_proxy_server.cpp b/src/dht_proxy_server.cpp
index cd6623d9492d34e47427a0c8fdc74128bfe6fb5c..91a1f350f513451210045912c42565ffc68e0466 100644
--- a/src/dht_proxy_server.cpp
+++ b/src/dht_proxy_server.cpp
@@ -150,7 +150,8 @@ DhtProxyServer::~DhtProxyServer()
 void
 DhtProxyServer::stop()
 {
-    printStatsJob_->cancel();
+    if (printStatsJob_)
+        printStatsJob_->cancel();
     service_->stop();
     {
         std::lock_guard<std::mutex> lock(lockListener_);