The process of sending the data through a pty or tty is desynchronized
from the state of the process doing the sending. If a process sends data,
then exits, it can be gone (and SIGCHLD fired) *long* before the buffers
are flushed to the receiving app. This has always been true (I first
remember noticing it on SunOS 4, but it was old even then) and is
essential for good performance over slower lines or under high load.
(Emacs is not the device. The device and buffering for it are kernel
entities. Emacs is merely the entity on the *master side* of the device.)