correctly leaving frame when click on canvas