IIRC the use case involves signal handling, which causes prepare_to_exit() to be called in handle_signals(). Once the signal handler returns, stdin is closed. The mainline continues to refer to the now closed file descriptor, and emits errors as consequence. The process terminates, but the path to exit is unsightly.
Ah, good catch. Thanks for the report and the patch! I don't like opening anything (even /dev/null) on an exit path, so I'll try to fix the problem in another way (tracking use of fd 0 in the mainline) over the next few days. If it proves too difficult, I'll commit something similar to your patch. -- Laurent