You handled it perfectly!
I am glad also you didn't get bit because it definitely hurts a lot and leaves scars (mental and physical) for many years) I should know because I still have both when I was attacked by a dog (a St Benard of all things! LOL) that was tied to a pole in front of a grocery store and it broke loose from it's leash.
And it jumped on me and bit me right on the left bicep and my instant reaction was to jerk my arm away and I learned later the WORST thing you can do (the cop told me) is jerk you arm or leg while they are biting because it will tear you wide open which it did. I guess you are supposed to not move while your get bit by a dog! NOT!!! LOL!
From one bite it tore my bicep wide open and I had to get a lot of stitches. I had a bag of groceries in my arms and they went all over the place and the guy who owned the dog ran out appologizing to me profusely and I remember he gave me $20.00 for my shirt which was almost torn off and bloody and he left quickly.
I was was in shock so bad I couldn't even describe him and he got away.
So I am glad you didn't get bit because it definitely is not fun! LOL!
I am fearful of dogs to this day and if one starts barking at me I immediately start looking for things to put it down. So far luckily I have never had to do it and I would not want to but big dogs to this day if they run up on me I will freak out! In fact even if a little chihuahua runs up on me I'll have anxiety!
And I still have a huge 8 inch scar on my arm and it was 15 years ago it happened.