diff --git a/config.ml b/config.ml
index 16631e3c7f7758b553aa48085c6d431fee7d93b4..9690f5b41d6b182122039ca29449dd36bb46e651 100644
--- a/config.ml
+++ b/config.ml
@@ -167,13 +167,13 @@ let detect_default_solvers () =
                   Stdlib.close_in in_channel;
                   Buffer.contents buf
               in
-              Utils.remove_on_app_mode tmp;
               if retcode <> 0
               then begin
                 Logs.info (fun m -> m "No solver `%s' found." S.name);
                 None
               end
               else begin
+                Utils.remove_on_app_mode tmp;
                 (* If available, we save a [config] for solver. *)
                 let version = version_of_solver solver cmd_output in
                 let config = { name = S.name; exe; version; } in
diff --git a/engine.ml b/engine.ml
index b95cab01bf35c8a066d7f7935f73aacdf698a656..a599d648be301a916630952931fc0eb1494eafb2 100644
--- a/engine.ml
+++ b/engine.ml
@@ -45,10 +45,11 @@ let check_availability solver config =
     let retcode = Sys.command cmd in
     let in_channel = Stdlib.open_in tmp in
     Stdlib.close_in in_channel;
-    Utils.remove_on_app_mode tmp;
     if retcode = 0
-    then
+    then begin
+      Utils.remove_on_app_mode tmp;
       Ok ()
+    end
     else
       Error
         (Format.sprintf
@@ -199,7 +200,6 @@ let exec_tasks ~raw_options solver config model tasks_htbl =
                 Logs.info (fun m -> m "Executing command `%s'." cmd);
                 try
                   let retcode = Sys.command cmd in
-                  Utils.remove_on_app_mode prop;
                   if retcode <> 0
                   then Error (Format.sprintf "Command `%s' has failed." cmd)
                   else begin
@@ -207,14 +207,16 @@ let exec_tasks ~raw_options solver config model tasks_htbl =
                     let result = extract_result solver ~log ~output in
                     Logs.app (fun m -> m "Result of `%s': %a."
                                  task.id Solver.Result.pretty result);
-                    Utils.remove_on_app_mode output;
                     if Solver.Result.equal result Solver.Result.Failure
                     then
                       Logs.app (fun m ->
                           m "See error messages in `%s' for more information."
                             log)
-                    else
+                    else begin
                       Utils.remove_on_app_mode log;
+                      Utils.remove_on_app_mode prop;
+                      Utils.remove_on_app_mode output;
+                    end;
                     Ok result
                   end
                 with _ ->