Fix cursor leaking issue.