1. on run {input, parameters}
  2. tell application "System Events"
  3. try
  4. repeat 10 times
  5. if not (exists process "iTunes") then return input
  6. with timeout of 60 seconds
  7. tell application "iTunes" to quit
  8. end timeout
  9. delay 1
  10. end repeat
  11. end try
  12. if not (exists process "iTunes") then return input
  13. do shell script "iTunes=" & (unix id of process "iTunes") & "
  14. for i in {1..10}
  15. do
  16. sleep 1
  17. kill -0 $iTunes || exit 0
  18. kill -9 $iTunes
  19. done 2> /dev/null"
  20. end tell
  21. return input
  22. end run

Force quit iTunes