Fix repl "plain" terminals enqueing events without ever dequeuing (#23641)

Bringing back part of #23631 which was reverted in #23636. Different but
related memory leak to what's described in #23008

Release Notes:

- N/A
5f417eda25Michael Sloan committed on 1/25/2025, 8:08:34 AM· committed by GitHubparent75b507d
1 file changedLine totals unavailable