Handle events before destroying objects

Register event handlers with the object manager, and fire the events
from within DiscardObjects before discarding any objects.

This mitigates problems where event handlers fired in global destruction,
after the object manager already had been garbage-collected