I might have just the thing you're looking for:
Check out 'Kiosk ScreenSaver' at
http://mithras.homeunix.net/downloads
It was my first Cocoa project ever, so it's not exactly polished; but it should do what you want. It's a simple screensaver that will do cleanup tasks after the user has been idle. Add the screensaver to /Library/Screen Savers, then configure it to execute a shell script.
In the sample shell script are 3 different ways to log out the user -
(1) presenting the user with the "Are you sure you want to log out?" dialog
(2) Logging the user out automatically, unless they have unsaved changes
(3) Forcing the user to log out, losing any unsaved changes.
Just edit the shell script, and remove the "#" comment in front of the type of log out you want to do.
Let me know if that works for you.