diff --git a/src/libs/utils/process_ctrlc_stub.cpp b/src/libs/utils/process_ctrlc_stub.cpp
index 5f3a8ab12c0554460223465b8b94feea2351a10c..0d05e4d0bdb5708701172bd471aaab9b2a280ee8 100644
--- a/src/libs/utils/process_ctrlc_stub.cpp
+++ b/src/libs/utils/process_ctrlc_stub.cpp
@@ -102,16 +102,19 @@ int main(int argc, char **)
     free(strCommandLine);
 
     if (!bSuccess)
-        return 1;
+        return -1;
 
     MSG msg;
+    DWORD dwExitCode = -1;
     while (GetMessage(&msg, NULL, 0, 0))
     {
+        if (msg.message == WM_DESTROY)
+            dwExitCode = msg.wParam;
         TranslateMessage(&msg);
         DispatchMessage(&msg);
     }
 
-    return (int) msg.wParam;
+    return (int)dwExitCode;
 }
 
 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
@@ -148,7 +151,10 @@ DWORD WINAPI processWatcherThread(LPVOID lpParameter)
 {
     HANDLE hProcess = reinterpret_cast<HANDLE>(lpParameter);
     WaitForSingleObject(hProcess, INFINITE);
-    PostMessage(hwndMain, WM_DESTROY, 0, 0);
+    DWORD dwExitCode;
+    if (!GetExitCodeProcess(hProcess, &dwExitCode))
+        dwExitCode = -1;
+    PostMessage(hwndMain, WM_DESTROY, dwExitCode, 0);
     return 0;
 }