fix crush on shutdown