How to use a variable to stop action

I want the timeline to stop at a certain point if a variable is set to “off”

In the action script for the said frame I have:

if (contest == "off") {
 stop();
}

This does not work however. Any Ideas? Thanks