There is a parameter which can be specified on a project or build configuration level: teamcity.buildQueue.restartBuildAttempts
By default it's value is 3, so TeamCity makes 3 attempts to restart build in case of unexpected finish. You can set it to 0 to disable this behavior.
You can set a parameter on a project or build config called teamcity.buildqueue.restartBuildAttempts .
Set it to 0 to disable the auto-restart. The default value for it is set to 3.