If a subsidiary thread calls exit(), its context is used (on Solaris at
least) for calling the atexit routines. If one of those routines cancels
the thread that called exit(), the exit itself gets cancelled and any
remaining threads are left running, possibly including the main() thread.
Thus the check in myAtExit() should have been to not cancel the current
thread; when this was tested, presumably only calls to exit() from the
main() thread were checked.