Temp var defined in global scope should be unset() after use

Fixes #15921