Fix calling protected method in register_shutdown_function.