You can control max with applescript, for example:
tell application "MaxMSP" to quit
executed from the script editor would close Max. You can also access the menus, move and click the mouse and trigger keypresses (although I think this requires a seperate toolkit, if memory serves it is called Extra Suites).
You can trigger scrips from inside max using [shell] which you can find here. The format is slightly different because [shell] communicates with the terminal so you'd need to use something like:
osascript -e 'set desktopPath to POSIX path of (path to home folder) as string' -e 'return desktopPath'
to find the current user directory. You also need to be careful to escape "quotes" and ,commas, and any other reserved characters you may find yourself needing. You can also execute applescript files saved to disk from within max.