Usually, the escape prefix is ‘^C^C’ as mentioned here, I.e. acad.doc.SendCommand("^C^C-PURGE…. ")
https://www.keanw.com/2006/08/cancelling_an_a.html
If a command is actually running, then there’s not much you can do because the document is most likely locked.
However, you can test if AutoCAD is ready to except a command by using the Application.GetAcadState method
https://help.autodesk.com/view/ACD/2024/ENU/?guid=GUID-0225808C-8C91-407B-990C-15AB966FFFA8
if you don’t need to be running out of process, and your version of CAD is compatible, you should try to run PyRx. It’s literally 100s of times faster than pyautocad. You get all or ActiveX and a big subset of ObjectArx