Stop progress indicator

OK, so I have a spinning progress indicator (circular) that I have set to start when something is running and stop it when the action is done. The problem is, say if an admin authorization dialog box comes up and I click cancel, the progress indicator keeps spinning and DOES NOT stop. Is there any way to make it force stop whenever the cancel button is clicked on any dialog in the program?

Hi,

pressing the Cancel button throws error -128, so catch the error and take care of your spinning indicator,
the do shell script line evokes the authorization dialog


try
	do shell script "echo " & "" with administrator privileges
on error number n
	if n = -128 then stopSpinning()
end try