fixed bug on shutdown