AppleScript app not responding force close
Any time an application does something like a execute a tight loop or perform a shell script that doesn't return, the user interface gets blocked because the app is not allowing the system time to process events.  In this case an NSTask can be used, since it runs in the background, and the application is just used to start and stop it.

The following needs to be saved as a stay-open application - the shell script is launched and terminated with the app:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

property task : missing value -- keep track of the NSTask

on run -- example
    tell current application's NSTask's alloc()'s init()
        set my task to it
        its setLaunchPath:"/bin/sh"
        its setArguments:{"-c", "/usr/bin/caffeinate -di"}
        tell it to |launch|()
    end tell
end run

on quit
    if task's isRunning then tell task to terminate()
    continue quit
end quit