Quitting a script

Basically, I have created an application with applescript, but it runs indefinitely unless I force quit it. The application does not have a quit function. Is there a way to make one on applescript?
I tried making a quit service for it, but for some reason it does not show up when I run it. How could I make the application be able to close whenever I want it to close?

Unless you need cleaning up on quit, you don’t need it.

On the other hand if your on quit handler does not have a continue quit, it will not quit gracefully.

What you need is a way out of the infinite loop you created. Probably.

Hello.

Could you please show us at least some of the code, (your quit handler), or where you suspect it doesn’t work?

For the quit handler, I tried using automator to create a service that will appear under services on the menu bar. I said no input for the specific application. Then I chose QUIT the specific application. But that is not appearing on the bar, I don’t know why. What is a quit handler? I just learnt applescript on Friday.

A quit handler, is an event handler inside an Applescript Application → Applet.

For your case, I’d try to error number −128, inside the Applescript action of your Automator Service, when you want it to quit.

You may be in luck! :slight_smile: