I need to restart the teamcity agent host (the server itself) after testing the build.
When I added a restart command at the end of my build steps, the artifact publishing gets cancelled.
The report says it was cancelled.
I then added a timer for the shutdown to give ample time for the artifact publishing to finish.
It resulted in a cancelled build because the agent starts building again (from the build queue) and the shutdown kicks in.