Crash in URLConnectionState::run() while app is shutting down

The application shutdown also happens on the message thread so it’s unlikely to be related to threading - it’s hard to say without seeing the full code but it looks like you might be having some lifetime issues with the shared_ptr in your app.

Try stripping it down to the bare minimum code in order to narrow down where the crash is coming from - this code for example shuts down cleanly:

#pragma once

#include <JuceHeader.h>

//==============================================================================
class MainComponent  : public juce::Component,
                       public juce::URL::DownloadTask::Listener
{
public:
    //==============================================================================
    MainComponent()
    {
        task = url.downloadToFile (juce::File::getSpecialLocation (juce::File::userDesktopDirectory).getChildFile ("download.zip"),
                                   {},
                                   this);
        jassert (task != nullptr);
        
        setSize (600, 400);

    }

    //==============================================================================
    void paint (juce::Graphics& g) override
    {
        // (Our component is opaque, so we must completely fill the background with a solid colour)
        g.fillAll (getLookAndFeel().findColour (juce::ResizableWindow::backgroundColourId));
    }
    
    //==============================================================================
    void finished (juce::URL::DownloadTask*, bool success) override
    {
        DBG ("finished");
        jassert (success);
    }
    
    void progress (juce::URL::DownloadTask*, juce::int64 bytesDownloaded, juce::int64 totalLength) override
    {
        DBG ("progress = " + juce::String ((float) bytesDownloaded / totalLength));
    }

private:
    //==============================================================================
    // Your private member variables go here...
    juce::URL url { "https://somefileontheinternet.zip" };
    std::unique_ptr<juce::URL::DownloadTask> task;

    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent)
};