I think, and I could be wrong, but once you declare a new class:
$variable = new class;
its scope is global and it doesnt go away.
You may want to check in the class functions for a way to see if the class has been decpared class_exists or something and make an if statement based on that.