diff --git a/doc/src/howtos/exceptionsafety.qdoc b/doc/src/howtos/exceptionsafety.qdoc
index 0eb674c2d47eb7ad97db285044c59709fdea6018..461f275e158da111fdbc08bfa57cee68f331128c 100644
--- a/doc/src/howtos/exceptionsafety.qdoc
+++ b/doc/src/howtos/exceptionsafety.qdoc
@@ -116,13 +116,15 @@
     QApplication app(argc, argv);
     ...
     try {
-        app.exec();
+        int ret = app.exec();
     } catch (const std::bad_alloc &) {
         // clean up here, e.g. save the session
         // and close all config files.
 
-        return 0; // exit the application
+        return EXIT_FAILURE; // exit the application
     }
+    ...
+    return ret;
     \endcode
 
     After an exception is thrown, the connection to the windowing server