Close handle on error