Git pre-commit hook that checks for open application
You don't say what problem you're running into, so let me guess.

If you're having trouble with how to phrase the "-- show a message and exit with non zero status" part, use the error command:

#!/usr/bin/env osascript

tell application "System Events"
    set apps to the name of every process whose background only is false
end tell

if "Some Application" is in apps then
    error "Some Application is running" number 5
end if


The number (5 in the example) doesn't matter; osascript will exit with status 1 no matter what number you choose. You don't have control over the formatting of the message, but the non-zero exit status will block the commit.

If you're having trouble getting the pre-commit hook to even run, remember to save it as .git/hooks/pre-commit and make it executable.

(update)
if you get the -10810 error try doing it with out System Events. Like this

#!/usr/bin/env osascript

set someApp to "Some App"
set appIsRunning to false
if application someApp is running then
    set appIsRunning to true
end if
if appIsRunning then
    error "Can't commit. Please quit Some App" number 5
end if