krytarowski added a comment. I'm not sure whether this is equivalent. I have a local patch to intercept _lwp_exit(2) and call destructor from this level. But I'm swamped by more serious issues like now, so I'm have scheduled it for later. https://reviews.llvm.org/D47448