Hi Blair,
The function to use is 'IfmSetSimulationControlFlag'. Using 'IfmCTL_ABORT' the current operation is immediately aborted (usually not recommended). Normally you'd use 'IFMCTL_BREAK' as the second argument, which will stop the simulation after finishing the current task.
Good luck!
Peter