My first guess would be the escaping somehow did not translate correctly for you. Try this:
osascript -e 'tell app "Script Editor" to quit'
If that works than you can break each piece of the command into a variable, test it by doing an echo $variable_name(name of your variable) one by one and then concatenate them together when you know the individual variables work.
Another option would be to do this in python and just call a python script, which I in fact do quite a bit:
ls = 'ls -l '
dir = '/home'
cmd = ls + dir
This type of format is a good way to wrap up shell command into python. Hope that helps!