Mika, I am using a couple of scripts called from the startkde script, as there doesn't seem to be a way to call scripts on session shutdown (that I know of). I have attached the gpgagent shutdown script I use. It just reads the process ID from the GPG_AGENT_INFO environment variable, and kills it.
Hope this helps, Toby
killgpgagent
Description: application/shellscript