Remove event handlers when terminating the sandbox