exit only from main thread