By setting trap one can run a logout script when a k-shell is being terminated. The built-in command trap in k-shell allows one to customize shell when a signal is received.
# Set to run $HOME/.logout script when shell is terminated
$ trap ‘. $HOME/.logout’ 0
# display list of signals setup
$ trap
trap — ‘. $HOME/.logout’ EXIT