added env check for register_shutdown_function