fix typo in example script

(cherry picked from commit 6471718866b2be6f3a62491e7c63dea8ca7681ce)

Conflicts:
	examples/threads.py
fix stopping of loop when timer returns falsy value

(cherry picked from commit 02874635b34059cbccdcfa7fbda1414b94eb4d18)
code cleanup; remove unneeded globals; fix check for None (== None → is
None)

(cherry picked from commit 13070c9ffd8ea500cf7f057ebca458fec63e6c7b)