Readline
rl.close()
Releases interface control and emits close. Closing the interface is not necessarily the same as destroying its input stream; manage stream ownership separately. Tested on Node.js 22.16.0. Example output (one line per entry): ["false"].
Formal Syntax & Structure
nodejs syntaxnodejs
rl.close()Return Value
undefined
Closes interface.
Working Example
Example Snippetnodejs
import { createInterface } from 'node:readline';import { PassThrough } from 'node:stream';import { once } from 'node:events';const input = new PassThrough();const rl = createInterface({ input });try { const done = once(rl, 'close'); rl.close(); await done; console.log(input.destroyed);}finally { input.destroy();}