Sorry man, no one have told on the comments if this guide works for the XT1040. I only have the XT1045. You can see the links from the other users to see if you find an answer there.
The phone stay in bootloader after the "mfastboot reboot" command?
I update the guide with a Changelog section. The problem here is that I already am in Lollipop. I can't test your problem, sorry.
Btw, seeing at your getvar all
I see that it says (bootloader) unlocked: no, (bootloader) iswarrantyvoid: no. Do you have unlock your booloader with Motorola?
If you have a stock ROM in version 4.4.3 or 4.4.4 the device will "automatically"(your confirmation) update via OTA. You must
have the latest Motorola Updates Services from the play store in order to update to 5.1 via OTA.
Hey, thanks for sharing your experience with us. I was just like you in 4.4.4 root. I downgrade to 4.4.3 using that same commands, and I have that same error in the "mfastboot flash partition gpt.bin". I ignore the error and proceed with the others, once I reboot, it was a successful flash to 4.4.3. I update via OTA and now I am too in 5.1
Thanks for sharing, I add your post to the guide.