Use a pointer to the commandserver to control the scope of it. Make one instance of QueueManagerPoolCache and clear it before the application stops.