Close all programs after 1min without user interaction
Here you go. A simple script you can setup to run automatically in the background using launchd or other means of your liking...

#
# From: http://www.dssw.co.uk/blog/2015-01-21-inactivity-and-idle-time
# Returns seconds system is idle, ie no user input...
#
set cmd to "echo $((`ioreg -w 0 -c IOHIDSystem | sed -e '/HIDIdleTime/ !{ d' -e 't' -e '}' -e 's/.* = //g' -e 'q'` / 1000000000))"

#
# How many seconds user can be idle before we log them out
#
set maxIdleAllowed to 60

#
# How frequently we check the idle time, in seconds...
#
set checkInterval to 30

#
# We loop forever...
#
repeat
    set secsIdle to 0

    try
        set answer to (do shell script cmd)
        set secsIdle to (answer as number)
    on error
        # May want to do something fancy here...
        exit repeat
    end try

    log secsIdle

    if secsIdle &gt; maxIdleAllowed then
        logUserOut()
    end if

    delay checkInterval
end repeat

on logUserOut()

# Exclude Finder at minimum because bad things happen, so I am told...
set excludedApps to {"Finder"}

tell application "System Events"
    #set oAppList to get id of every application process whose background only is false
    set {processList, idList, pidList, bidList} to the {name, id, unix id, bundle identifier} of (every application process whose background only is false)
end tell

set i to 0
repeat with p in processList
    set i to i + 1

    log "ID: " &amp; item i of idList
    log "PID:" &amp; item i of pidList
    log "Name: " &amp; p
    log "Bundle: " &amp; item i of bidList

    if p is not in excludedApps then
        try
            log "Quit with out saving app with id: " &amp; item i of idList

            # timeout to prevent blocking by certain apps...
            with timeout of 1 second

                # Use bundle id for some odd apps... soffice i'm talking to you!?!
                tell application id (item i of bidList) to quit saving no

            end timeout

        on error
            try
                log "Giving up, killing pid: " &amp; (item i of pidList)
                do shell script "kill " &amp; (item i of pidList)
            end try
        end try
    end if

    delay 1

    log "" &amp; return
end repeat

# Finally, with all apps closed, kill our session...
tell application "loginwindow" to «event aevtrlgo»

end logUserOut


EDIT: Your question has already been answered really, it's just that your action, after idle time, is different. Take a look here at,

How can I automatically launch an application whenever the Mac goes idle?

EDIT2: There you go. Added routine to close apps nicely if possible, and if not, kill them and logs out.