Trigger When Process Complete

For Example if I use terminal to Repair Permissions (sudo diskutil repairPermissions /) When repairs are complete or finished, how to activate macro to quit terminal.

You can trigger a macro from a script as described in the Scripting section of the documentation, or as described on this thread

Thank You, I was thinking how to trigger a macro when the terminal or other applications reach (%CPU is 0.0) in activity monitor or application becomes idle for a certain amount of time. Thank You

Well for the Terminal I found this tip which helps with window clutter for terminal app. http://www.cnet.com/news/terminal-tip-close-windows-after-clean-exit/
or
sudo diskutil repairPermissions / ;osascript -e ‘tell application “Terminal” to quit’ & exit