This is explicitly called out and handled in lines 151-155.
https://git.savannah.gnu.org/cgit/hello.git/tree/src/hello.c
Here's the comment:
/* Even exiting has subtleties. On exit, if any writes failed, change
the exit status. The /dev/full device on GNU/Linux can be used for
testing; for instance, hello >/dev/full should exit unsuccessfully.
This is implemented in the Gnulib module "closeout". */