title: Abort execution of parsim
body: <p>For the use case of being able to abort parallel simulations with a MATLAB GUI, I would like to stop all scheduled simulations after the user pressed the Stop button. 
  All simulations are submitted at once using the <a href="https://www.mathworks.com/help/releases/R2017b/simulink/slref/parsim.html" rel="nofollow noreferrer"><code>parsim</code></a> command, hence something like a callback to my GUI variables (App Designer) would be the most preferable solution. </p>
  
  <p>Approaches I have considered but were not exactly providing a desirable solution:</p>
  
  <ul>
  <li>The <a href="https://www.mathworks.com/help/releases/R2017b/simulink/slref/simulationmanager-app.html" rel="nofollow noreferrer">Simulation Manager</a> provides the functionality to close simulations using its own interface. If I only had the code its Stop button executes...</li>
  <li><code>parsim</code> uses the <a href="https://www.mathworks.com/help/releases/R2017b/simulink/slref/simulink.simulationinput-class.html" rel="nofollow noreferrer">Simulink.SimulationInput</a> class as input to run simulations, allowing to modify the <a href="https://www.mathworks.com/help/releases/R2017b/simulink/slref/presimfcn.html" rel="nofollow noreferrer"><code>preSimFcn</code></a> at the beginning of each simulation. I have not found a way to "skip" the simulation at its initialization phase apart from intentionally throwing an error so far.</li>
  </ul>
  
  <p>Thank you for your help!</p>
  
  <hr>
  
  <p><em>Update 1</em>: Using the <code>preSimFcn</code> to set the the termination time equal to the start time drastically reduces simulation time. But since the first step still is computed there has to be a better solution.</p>
  
  <pre><code>simin = simin.setModelParameter('StopTime',get_param(mdl,'StartTime'))
  </code></pre>
  
  <hr>
  
  <p><em>Update 2</em>: Intentionally throwing an error executing the <code>preSimFcn</code>, for example by setting it to</p>
  
  <pre><code>simin = simin.setModelParameter('SimulationCommand','stop')
  </code></pre>
  
  <p>provides the shortest termination times for me so far. Though, it requires catching and identifying the error in the <code>ErrorMessage</code>of the <a href="https://de.mathworks.com/help/simulink/slref/simulink.simulationoutput-class.html" rel="nofollow noreferrer"><code>Simulink.SimulationOutput</code></a> object. As this is exactly the "ugly" implementation I wanted to avoid, the issue is still active.</p>