Fixed race when cancelling downloads

The main thread might set the progress report to "finished" and then the
download thread gets some more data and sets it back to "in-progress"
before the cancel takes effect. This meant that the GUI would continue
showing the progress bar even after cancelling.