safer test for currently running app

The previous version could fail if the specified bundle was not installed.
Here we tell "System Events" until determining it is safe to do otherwise.
Merge pull request #2026 from rolandwalker/safer_quit_uninst

safer test for currently running app