diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp
index a64d2d46f2..bf07b29441 100644
--- a/programs/cli_wallet/main.cpp
+++ b/programs/cli_wallet/main.cpp
@@ -61,6 +61,12 @@
 # include <csignal>
 #endif
 
+#ifdef WIN32
+   #define QUIT_CURR_THREAD TerminateThread(pthread_self(), 0)
+#else
+   #define QUIT_CURR_THREAD pthread_cancel(pthread_self())
+#endif
+
 using namespace graphene::app;
 using namespace graphene::chain;
 using namespace graphene::utilities;
@@ -283,21 +289,13 @@ int main( int argc, char** argv )
          fc::set_signal_handler([&wapi, &wallet_file](int signal) {
             ilog( "Captured SIGINT not in daemon mode" );
             wapi->save_wallet_file(wallet_file.generic_string());
-            #ifdef WIN32
-               TerminateThread(pthread_self(), 0);
-            #else
-               pthread_cancel(pthread_self());
-            #endif
+            QUIT_CURR_THREAD;
          }, SIGINT);
 
          fc::set_signal_handler([&wapi, &wallet_file](int signal) {
             ilog( "Captured SIGTERM not in daemon mode" );
             wapi->save_wallet_file(wallet_file.generic_string());
-            #ifdef WIN32
-               TerminateThread(pthread_self(), 0);
-            #else
-               pthread_cancel(pthread_self());
-            #endif
+            QUIT_CURR_THREAD;
          }, SIGTERM);
 
          wallet_cli->wait();