[python] How to close a thread from within?