Try to add to your script:
class ExecutionMonitor(eventHandler):
def onExecutionStatusChange(self, executionStatus):
if executionStatus == executionStatus.Go:
breakin()
mon = ExecutionMonitor()
This code will forcibly break running of the target process