class library: protect EnvGate when released too early
This is a temporary precaustion, see discussion about #700.