fixed cleanup on shutdown