Fix disposing of platform types. Fixes #15375.

The handle field was getting cleared out before we were calling 'release'
on it, causing us to leak every instance of a platform type. Putting the
handle in a local variable before it's cleared out fixes this.