resolve android thread issues by reorganizing app termination