rm gloabals, rm double-quotes, added r

Removed double-quotes, global variables. Added `r` variable for the on `exit` event example.