Cluster termination using python script, sending return code 1

Harsh-dataB
New Contributor II

i have used a cluster termination logic for terminating a cluster , the issue is , the cluster is not terminating gracefully , returns a return/exit code 1

The cluster is completing all the spark jobs, but it goes on long running state, hence i created a logic for terminating the clusters getting in long run state,

is there any way to change the return code to 0 , or terminate the cluster gracefully .