[ubuntu] shutting down system when torrent download has no peer

view story

http://ubuntuforums.org – I use Transmission to download torrent file. So i need to run a shell script that will shut down the system when that torrent can not search any peer or the download is stopped. can you please help me to make the shell program. (Hardware)