[#3882] Fix issue with expired WeakRef callbacks

- Added code that validates that we have a callback from the listener
  prior to executing it. If not, we unregister the listener. This
  reinstates the original behavior from the tests (which were failing
  when WeakRef was present).
Merge branch 'hotfix/3882' into develop

Forward port #3882