updated for version 7.4.040
Problem:    Valgrind error on exit when a script-local variable holds a
	    reference to the scope of another script.
Solution:   First clear all variables, then free the scopes. (ZyX)
Added tag v7-4-040 for changeset 8336fd924e05