Automatically close Chrome tabs (for certain websites)
There's a Macworld article that may help you do what you want, although it focuses on logging out idle users in a fast-switching environment rather than closing applications. That said, if you have a launch agent monitoring the idle state of the user, it should be possible to have it trigger an AppleScript that brings Safari into focus and tells it to exit.

It might be easier to just have their accounts logged out when they're idle.