Packer yaml build task intermittently hangs forever while trying to power off the VM

We have a Packer template that builds a Windows-based VM image using the Packer build task in an Azure DevOps build pipeline. We use a standard VM image from the Azure gallery and add some custom applications to it. From a log perspective all seems well and yet at the point where the Packer process tries to power off the VM in order to generalise the image, the process hangs forever, or at least until the build process times out.

At other times, despite the Packer logs being identical, the process completely succeeds in a timely manner.

Also, we have a similar process for a standard Ubuntu image and never have any issues at all.

What can I do to either make this process more reliable or get deeper into the details to determine a root cause?