Use an iterator to clear runspaces during shutdown.