Situation
I have set up an environment where users can login from multiple endpoints and use tmux, screen ... so when they end their work they can either logout of their ssh session which doesn't kill any process kept in any terminal multiplexer, they can either do a pkill -u ${USER} or killall -u ${USER} to kill all their process, for that I wrap the function inside a script named fulllogout.
Problem
When running pkill -u ${USER} or killall -u ${USER}, the killing process can kill itself or it's shell before killing all other processes which result in some process kept alive.
How can I do it successfully without allowing elevated rights ?
pkilldoesn't kill itself. Your problem is probably that some processes are ignoring theTERMsignal (eg. interactive shells), or are stopped, in which case the signal will only reach them if woken up. "Elevated rights" will not help with any of those. I suggest you do afulllogout()( pkill -HUP -u "$USER"; pkill -CONT -u "$USER"; pgrep -u "$USER" && { sleep 10; pkill -KILL -u "$USER"; } &)instead (untested).