The INSTANCESTOPPING checks to see if a request has been made to stop a message flow, and returns a Boolean value of true if a request has been made.
The message flow function returns TRUE if a request has been made to stop all processing within a message flow, otherwise it returns FALSE.
/*
* Do not code loops like this as it never increments loopCounter
* but with the INSTANCESTOPPING() check it would exit when the flow is stopped
*/
declare loopCounter integer 0;
INFINITE_LOOP : WHILE (loopCounter < 1000) DO
IF (INSTANCESTOPPING() = TRUE) THEN
LEAVE INFINITE_LOOP;
END IF;
END WHILE INFINITE_LOOP;