Background and Foreground are different processes and they aren't sharing data memory. So basically you can't set any boolean in one app and just check it in another.
But since you have communication between two apps already, probably using ApplicationManager.postGlobalEvent()
, you can add another event "Exit".