diff --git a/Python_script/prototype.py b/Python_script/prototype.py
index 7fc36bfea9401f85eac9a61f79ab9e334b82631e..1ddd6467fde3dc93d89b07fb38bfa2650616415d 100755
--- a/Python_script/prototype.py
+++ b/Python_script/prototype.py
@@ -112,14 +112,11 @@ class Measurements:
                     self.perform_single_measurement(self.output_basename+'_'+str(measurement_number)+'.csv', next_temp,
                                                     next_hum, next_soaking, next_reads)
                     measurement_number += 1
+                    if process_sync.stop_measurement.is_set():
+                        break
 
             except KeyboardInterrupt:
                 pass
-            except MeasurementPlot.PlottingError:
-                # Just the plotting failed, probably because the window was closed
-                # The measurement was partly done and should be plotted, so the following code has to see the correct
-                # number of successful measurements
-                measurement_number += 1
 
         plt.close()
 
@@ -156,6 +153,8 @@ class Measurements:
                                                    + str(target_hum) + ' rel. hum.',
                                                    color="red")
                 self.perform_single_measurement(output_name, target_temp, target_hum, soaking_time, n_stable_reads)
+                if process_sync.stop_measurement.is_set():
+                    break
 
         except KeyboardInterrupt:
             pass