support exit in non-mainthread