This Commented CUE demonstrates how to use the built-in function close() to close a struct.

example.cue
package example

// _x is an open struct
_x: {
	a?: int
	b!: bool
	c?: string
}

// "ok" is an open struct
ok: _x & {
	a: 42
	b: true
	c: "a string"
	d: "an additional field"
}

// "notOk" is the result of unifying a closed
// struct with at least one field not mentioned
// by the struct ("d")
notOk: close(_x) & {
	a: 42
	b: true
	c: "a string"
	d: "an additional field"
}
TERMINAL
$ cue eval -i
ok: {
    a: 42
    b: true
    c: "a string"
    d: "an additional field"
}
notOk: {
    a: 42
    b: true
    c: "a string"
    d: _|_ // notOk.d: field not allowed
}