An alternative simple solution could be to use the QoS of your router (Quality of Service), this may allow you to give higher priority to certain protocols (i.e. HTTP/HTTPS).
If you don't have QoS on your router the only way are the one explained above.
One more link:
Be aware that if you give high priority to HTTP or HTTPS, then, almost probably, your torrent won't work anymore, this is because many applications use the HTTP protocol to exchange data over the network, so there will be always something matching the iptable rule.
I'd rather advice to use a Command line version of bittorrent, like rtorrent, this way you can write a simple shell script that will change the torrent download throttle and then execute firefox (or whatever).
You can also stop rtorrent downloading after certain conditions.
Hope it helps...