Add support for registering destructors for TLS
Do python cleanup properly on thread exit