Atexit is not working, if the main thread has died, and the child remained alive.
```
import time
import atexit
import threading

class Foo(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)
        self._stop_run = False

    def stop(self):
        self._stop_run = True
        print("Called stop()")

    def run(self):
        while not self._stop_run:
            time.sleep(1)
        print("Done Foo()")

foo = Foo()
atexit.register(foo.stop)
foo.start()
#foo.stop() # XXX: Works ONLY if this code has been called directly
print("Done __main__")
```