fix a bug in cs_close(): improper check on handle value