Build is being continuously built in Bamboo even after the script has finished running using UFT in the remote agent.

Am using the option Stop Build to manually stop it.
I need to have the build stop automatically so that my build is reported to be successful because when stop manually, it is being reported as not built.