I usually lock something when the majority of the thread is made up of posts I would have to delete to get the thread back on track. If I can clean it up by batch deleting 5 or 6 posts and it can continue on successfully after that, I'll do it. But if it's gone into an argument deleting posts often doesn't stop the argument. And there's no way in hell I'm going to sort through trying to clean up 20+ bad posts to salvage 10 good ones. Leaves a very cluttered thread with all those deleted post placeholders, heh.
In response to Julian's link to a specific thread, I locked it because your question had been answered, and it was going way off topic, to random posts. And also, I was a bit annoyed over drama going on in the forum, and I was more inclined to lock threads than I usually am to try to put a stop to it.