fix close crash in linux and mac