added a mechanism to callback at the exit of AsuraThread.