resolve anr when exit and remove some unuse code