Here’s a WordPress plugin that closes comments on all posts older than 21 days: Auto-Close Comments.
It runs a query and update against the database when any one of the following occur:
- A post is published (but not saved as a draft), edited or deleted;
- A comments is posted, edited or deleted;
- A trackback is posted; or
- A template is saved