I think you need to be more specific. From your post, it says you want to close all queries if no one talks. No one talks where? In the specific query window? In any query window? In all queries and channels? What about if you talk?
Basically, it just needs a timer and a /close command.