Fixed #952: register_[pre_]shutdown_function never throw