Fix double-deletion on shutdown.