We recently had a build that was hung on TeamCity. When we cancelled it, the build just stayed around saying it was cancelling. After googling for the solution, I couldn't find one. So this is what I did to clear it.
Go into team city and find the directory and machine that the build is on (assuming you're using multiple build agents). It will be something like C:\TeamCity\buildAgent\work\dc426554e8b0f33. Stop the Build Agent on that machine,
- net stop "TeamCity Build Agent Service"
- Delete the offending dir.
- net start "TeamCity Build Agent Service"
Then go to the webserver machine and do this;
- net stop "TeamCity Web Server"
- net start "TeamCity Web Server"
I hope this helps someone.