fixed closing cursor on closed connection