I did not want to say your script has errors.
If it is about Startup/Shutdown/Logon/Logoff scripts, I think these run per default maximum 10 minutes. I think this can be changed via Group Policy
Computer COnfiguration --> Administrative Templates --> System/Scripts --> Maximum wait time for group policy scripts
But I presume that is not what you were looking for