This error occurs when there is an integrator in the Simulink model.
Open Configuration Parameter, set the diagnostic "Inf or NaN block output" to error, you will get the error as follows:
An error occurred while running the simulation and the simulation was terminated
- Block 'BlockName' outputs 'NaN' for element x of output port x at major time step 7.5
where BlockName is the block in which error is thrown.
This blocks has a divide by zero, which creates a Inf that when fed to an Integrator, generates this error.
So, avoiding division by zero in the logic might mitigate the problem.
Hope this helps!