handle leave events (fix #1)