Try a Google search for this - someone presumably has done it before.
However, excel is not set up to do this, so you'd need to keep track of
activity yourself. This means that you'd have to trap several events
(probably cell and sheet focus change events) to make sure you didn't miss
activity, then have your timer check this before saving and closing.
I don't know if you're able to close Excel entirely in this way, but you
would be able to close the workbook.