Ensure one can call DisposeEnvironment during event callbacks. am: 6a0e0b242a
am: 0f815f12f2

Change-Id: Ic8fe717372182fcc47383f5e0239fc28bbb6998e