feat(leave): introduced onPreLeave event

Fixes #28, #43, #46