Pause or stop the program

Which method should be called when the daemon detects abnormal data to pause or stop the program? please give me your advice

Did you try access to dashboard? (port 29999)

https://www.universal-robots.com/articles/ur-articles/dashboard-server-cb-series-port-29999/

I got the program to stop using these commands in python

def start_socket():
    HOST = "0.0.0.0"    # The remote host
    PORT = 30002              # The same port as used by the server
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((HOST, PORT))
    return s

def close_socket(s):
    s.close()

def send_command_to_ur(s, command):
    s.send(command)

def stopRobotProgram():
    c = (
	    "halt" + "\n"
    ).encode()
    send_command_to_ur(s, c)