Add null checks before calling PopUpManager.removePopUp()

While investigating issue #8344, I hit the exception described in https://groups.google.com/forum/?fromgroups#!topic/brackets-dev/IurHDG7AS7E, so this prevents that exception.

cc @peterflynn