Cleanup correctly on shutdown