Script does not work as expected

Yeah, sorry. I missed the else statement sandwiched between the parentheses. That’s what I get for reading code on my phone, particularly since I’m kind of a neat freak when it comes to formatting.

As @JustinG pointed out, you need the function to be a parameter within the timer. You might have gotten confused by people using createTimer as simple delays:

createTimer(now.plusSeconds(30)) [ DO STUFF ]

I do this whenever I’m not worried about cancelling the timer.

This might be the post you were thinking of. For future reference, I searched “timer.cancel” to find it.

Note that the example uses two separate rules: one to start the timer and another to cancel it. I’m not sure if that works in MainUI (I haven’t tried it). The IF/ELSE should work fine, except for this:

As @Netboy3 points out, you stated that your rule only triggers on a CLOSED state. You need it to trigger whenever the contact changes to any state, so that it can react to CLOSED or OPEN.