Tidied up shutdown.