move the release code to OnDestroy