Make the progress dialog box `Cancel` operation more robust.

The progress dialog I use, along with the async task thing I cobbled together is still somewhat race prone and fragile, and sometimes leaves the dialog box up instead of hiding it.

I mostly see this when testing on my VM. The code in general could use an overhaul and cleanup since it's kind of kludged together.