Code cleanup.  Also installed atExit so threads could be stopped if running.
Code cleanup.  Also installed atExit so threads could be stopped if running.

after5cst/python-extend-with-threads,after5cst/python-extend-with-threads