There is a parameter which can be specified on a project or build configuration level:
teamcity.buildQueue.restartBuildAttempts
Remember that by default it's value is 3, that means, TeamCity makes 3 attempts to restart build in case of unexpected finish. But if you want to disable this behavior, you can set this value to 0.