protected the timer work in terminate with a lock. fixes #2