TypeError thrown

curl_close(): Argument #1 ($handle) must be of type CurlHandle, null given