Fix shutdown function being always None

Problem reported by @IvanMalison