If I run an application with graphical interface using the X11 forwarding under ssh, then when I type the command "exit", the ssh will performe a logout but will keep running.

What is the clean way to end the ssh once all applications using the X11 forwarding have been closed?

For instance, if I do :

$ ssh -X name@host "gedit; echo completed; exit"

A window running gedit does popup and when I close it "completed" is written into the terminal. Moreover, I run the "w" command on the server, I see that the user did logout. On the other hand, the ssh command keeps running :

$ ps aux | grep ssh\ | grep -v grep
name 31263 0.0 0.0 5508 2736 pts/5 S+ 14:15 0:00 ssh -X name@host gedit; echo completed; exit

Thanks for your help