It seems that the arguments are only seen by the initial part of the environment. One way around this is to set a dummy variable in the top of the environment and then use it when you close the environment.
Good Bye, cruel world!
Of course, this won't work with nesting, but if you are going to nest these environments then you could set a counter and make the dummy variable name depend on the counter. Environments like
enumerate etc use a similar trick.