Added an explicit close cursor call.