Fix result fetching, only try to close result once, make error return 0.