Keep in mind that it's normal for it to take some additional time past the Spark UI's completion for the Dataproc job to finish, first just for the driver program to exit after the YARN application is done, but also then for the status to propagate out to Dataproc's side and for backend book-keeping to be completed. This might be on the order of 5-20 seconds or so.
Next time this happens, please take a screenshot if possible of the Spark UI page indicating completion time, plus the YARN page indicating YARN's application completion time, and then also a screenshot of your
console.cloud.google.com page showing the Dataproc job still not completed along with its jobid.
If you don't want to share those more broadly on this list, you can send them privately to
dataproc...@google.com for Dataproc engineers to take a look.
Also, you should check "gcloud dataproc jobs describe <your jobid>" to see if that reported completion, in case it's just a browser refresh issue where the Dataproc UI just didn't update with the job completion.