What kind of command do you want to perform?
You could use an on DISCONNECT event, but if you want to perform something on the server connection you're closing, then it won't work.