Causing either ffmpeg or mpg123 to exit when the streaming is interrupted is quite easy!
You need to use a timeout parameter of a few seconds. I typically set it to 10 seconds.
For mpg123 it's the command line parameter --timeout 10 and for ffmpeg it would be --timeout 10000000
Note that for mpg123 you enter seconds, but for ffmpeg you enter micro-seconds, thus the extra 6 zeros to go from micro to second.
That said I am not sure you would want to exit those players if the stream broke down! Why? Simply because asterisk/FreePBX would immediately call the same command line again mindlessly. If that happened your DNS look ups will go through the roof and CPU utilization jump to saturation.
The smart way to address this issue is to take the control away from asterisk/FreePBX.
You can do it by creating a bash script which we will call for instance "playstream" and make sure that it actually never exits!
In asterisk/FreePBX you would simply call playstream on the command line where you usually enter your ffmpeg or mpg123 line.
Inside the playstream script file you would run one or more MOH command lines like the following:
/opt/ffmpeg/bin/ffmpeg -f s16le -ac 1 -ar 8000 -vol 32 pipe:1 -timeout 10000000 -i
http://ais-sa1.streamon.fm/7833_128k.aac;
/usr/bin/mpg123 --timeout 10 -q -s --mono -r 8000 -f 8192 -b 0
http://stream.live.vc.bbcmedia.co.uk/bbc_world_service;
(The first one streams WHUD the second is for BBC)
So, if the first one ever interrupted for more than 10 seconds, the script would go to the next line and that would run until it stopped streaming for more than 10 seconds.
Of course you should have enough sources and the proper logic so that this script file actually never exits!
You can use loops, counters, random calls, etc so that you get a constant flow of feeds.
You can also use the case statement so that you can pass to the script file a radio channel parameter, like the call letters WHUD, KABL, WINS, WCBS and connect to the proper ffmpeg or mpg123 instruction inside the script file. Then again, you would supplement the command in such a way that if that stream is interrupted the script starts another (maybe) random stream or even a static music file to prevent the script from exiting.
So if you can do basic scripting the sky is the limit.