AppleScript: "tell me to quit" - conditional on the environment?
Current Application

You can get the name of the current application. If the name is Script Editor, then your AppleScript is being run within the editor:

display dialog (name of current application as text)


Detecting the Environment

Alternatively, your AppleScript can access environment variables through the system attribute command. You should be able to determine your process through this information. To see the HOME path environment, use:

display dialog (system attribute "HOME")


Stopping an AppleScript

To stop the script use the return command. In the AppleScript snippet below, the dialog is never displayed:

return
display dialog "Hello World"


return exits the current routine within AppleScript; much like return in other languages such as c. Called within the context of the main AppleScript routine, there is nothing to return to, so the script finishes.

Compare this to tell me to quit, where the snippet causes a quit AppleEvent to be issued to the current process.