Code snipped posted in the above link will not work all the time as expected (in my experience). However you cant write the java script directly, first you have define some API (webMethods flow services) to actually invoke them via UI. The UI code can be on js,ajax,html etc
As per my knowledge starting from wM 8.2 IS and above you have an option to check the currently running services for a longer time (threads) and you can either cancel the thread or kill a thread if you are sure that it must. I would like to suggest you to check the actual flow/java services being called on the back end. In this way you will be able to get the current thread and you can accomplish your job. You can also generate thread dump from WmRoot services, even restart of IS can be achieved. Moreover you may also explore command central if provides any out-of-the-box feature to handle such requirements as I have not fully explored CC.
#Integration-Server-and-ESB#webMethods#B2B-Integration