I keep some stuff in a file 'XXX.gpg' which I read and edit with emacs auto encryption mode.
In some cases I forget to close the buffer for a long time which is some kind of risk.
I would like to have the buffer automatically saved and closed after some time (of inactivity).
You could use run-with-idle-timer
to construct a function doing exactly what you want.