Generally the isscreenclosed() event is what you need to handle. Here are some bits of code that might be helpful:
else if msg.isscreenclosed() then
return -1
On roImageCanvas however, you are looking for msg.isRemoteKeyPressed():
if msg.isremotekeypressed() then
ndx=msg.getindex()
if ndx=0 or ndx=2 then
screen.close()
return -1
end if