improved the shutdown of the app. stopped rogue threads hanging around