Check out this useful post from Cyril Fauvelle on the ins and outs of the dreaded MScriptUtil.
This kind of stuff is why I reserve API programming for only the knottiest of tasks. maya.cmds won't clean-exit your Maya session if you reverse two lines by accident. However, sometimes there's no alternative... Here's hoping API 2.0 matures quickly and we can all forget all of this pointless distraction.
The blog has been retired - it's up for legacy reasons, but these days I'm blogging at blog.theodox.com. All of the content from this site has been replicated there, and that's where all of the new content will be posted. The new feed is here . I'm experimenting with crossposting from the live site, but if you want to keep up to date use blog.theodox.com or just theodox.com