title: detect when the application is no longer active
body: <p>I need to terminate my background threads when the app is terminated. What is the least-convoluted way to accomplish this?</p>
  
  <p>All i can think of is to keep track of the number of running activities, by having each activity report onCreate and onDestory events to Application and when the number reaches zero, assume the app is terminated?!</p>