I also came across a similar situation where I wanted to kill the timer I started with:
(setq my-timer (run-with-timer 5 5 'my-func))
but
(cancel-timer my-timer)
did not work because he said that my timer was not set (I do not know why this happened).
In addition to the method of the first poster, it can be killed with:
(cancel-function-timers 'my-func)
This cancels all timers calling the 'my-func function.
To kill him by changing the timer list, which I also checked, I did the following:
(length timer-list) ;; I had two timers..one good, one bad (cdr timer-list) ;; I verified the last was the one I wanted to keep (setq timer-list (cdr timer-list)) ;; I reset timer-list
Obviously, this list structure will be different, so you will have to adjust it accordingly. Replace "timer-idle-list" if you started your timer with (run-with-idle-timer)
This should also work if you started your timer with "gamegrid-start-timer" and "gamegrid-kill-timer" does not work, since "gamegrid-start-timer" is essentially just a shell for "run-with-timer "
source share