Replace an inappropriate global object with a closure variable.