introduce _cleanup_close_ macro