onexit

“onexit” is a script attribute. It is run every time that a player leaves an object (room).

See also enter.