You should be able to create a macro like:

/stopcasting
/run CloseAllBags(); CloseTradeSkill(); CloseCraft(); CloseItemText();

There are a number of other API calls you could use, check http://www.wowwiki.com/World_of_Warcraft_API for them.