Spanning-tree will block ports automatically; That's what it's there for. You don't have to block ports manually, but manipulate spanning-tree so it will do it for you.
Here is a hint: http://www.astorinonetworks.com/2011/06/30/spanning-tree-port-priority/