If you want to stop the timer, just globalstoptimer = true. I did apply a slight change so the timer value is shown after the timer is aborted.
;mandotimer.sqs
;
;Arguments:
; resolution in seconds, step in second between timer checks
; timer limit in seconds
; timer direction 1 counting up, -1 counting down
; Show elapsed time every timer check? true/false
; script to be executed when timeout, "" if not needed
; script to be executed if timer is stopped before timeout, "" if not needed
;
; To end timer before timeout, set gobal variable globalstoptimer to true
; global variable globalelapse keeps elapsed time since timer start
;
;Example:
; 1 hour left to accomplish something (countdown type), timer checks every 5 seconds showing elapsed time
; [5, 3600, -1, true, "gameover.sqs", "youwon.sqs"]exec"mandotimer.sqs"
;
_resolution = _this select 0
_limit = _this select 1
_dir = _this select 2
_show = _this select 3
_scripttimeout = _this select 4
_scripttimerend = _this select 5
_elapsed = 0
globalstoptimer = false
?_dir == -1:_elapsed = _limit;_limit = 0
#check
_timeini = time
@((time - _timeini) > _resolution)
_elapsed = _elapsed + _dir * _resolution
?!_show:goto "continue"
_h = (_elapsed/3600)- ((_elapsed/3600)mod 1)
_sr = _elapsed - _h*3600
_m = (_sr/60)- ((_sr/60)mod 1)
_s = _elapsed - _h*3600 - _m*60
_hp = "0"
_mp = "0"
_sp = "0"
?_h > 9:_hp = ""
?_m > 9:_mp = ""
?_s > 9:_sp = ""
?_show:cutText[format["%1%2:%3%4:%5%6",_hp,_h, _mp,_m,_sp,_s], "PLAIN DOWN"]
#continue
globalelapsed = _elapsed
?globalstoptimer: goto "timerend"
?_elapsed != _limit:goto "check"
;Uncomment next line if you want a message indicating timer ended
;?_show:cutText["TIMER END REACHED", "PLAIN DOWN"]
?_scripttimeout != "":[]exec _scripttimeout
exit
#timerend
;Note the change here
cutText[format["%1%2:%3%4:%5%6",_hp,_h, _mp,_m,_sp,_s], "PLAIN DOWN"]
?_scripttimerend != "":[]exec _scripttimerend
exit