ping -c 1800 localhost; killall iTunes
The 1800 is the timeout in seconds -- 1,800 seconds is 30 minutes (30min * 60sec/min). Note that killall iTunes will happen one second before your timeout, so if you want exactly 30 minutes, you should enter 1801.
If you don't want to see all the ping packets during the timeout period, you can dump the ping output to null like this:
ping -c 1800 localhost >nul; killall iTunes
Cancel the command by pressing Control-C any time before the timeout occurs
[robg adds: killall is probably the dangerous way to do this. A slightly safer version, which allows the app the opportunity to exit gracefully, would be to replace the killall bits with this: osascript -e "tell application \"iTunes\" to quit". If the program needs you to do anything before quitting (save a document with unsaved changes), it will prompt you (via its normal interface in the GUI) to do so. This safer solution, however, wouldn't be very useful if you're attempting to run this timeout script over a remote login (ssh) connection.]

