gsi_tool: Fix progress bar quirk.

If the progress bar receives a sequence like:
  T+0 "create system" 99%
  T+1 "write gsi" 1%

It'll draw the "create system" bar at 99% and leave it there forever.
Ensure that FinishLastBar() gets called before moving onto a new
operation.

Bug: 122556707
Test: manual test
Change-Id: Ic27ebdd41a088f621a2885a9c2d1db7079ab5223
diff --git a/gsi_tool.cpp b/gsi_tool.cpp
index 3b6886c..c5921da 100644
--- a/gsi_tool.cpp
+++ b/gsi_tool.cpp
@@ -77,9 +77,7 @@
     ~ProgressBar() { Stop(); }
 
     void Display() {
-        if (worker_) {
-            Stop();
-        }
+        Finish();
         done_ = false;
         last_update_ = {};
         worker_ = std::make_unique<std::thread>([this]() { Worker(); });
@@ -95,6 +93,9 @@
     }
 
     void Finish() {
+        if (!worker_) {
+            return;
+        }
         Stop();
         FinishLastBar();
     }
@@ -128,6 +129,10 @@
     }
 
     void FinishLastBar() {
+        // If no bar was in progress, don't do anything.
+        if (last_update_.total_bytes == 0) {
+            return;
+        }
         // Ensure we finish the display at 100%.
         last_update_.bytes_processed = last_update_.total_bytes;
         Display(last_update_);