There's a misunderstanding here. When the C runtime gets control back from main(), it calls exit(status) which flushes all open stdio buffers. Success or failure of that does not affect the exit status.

D does not need to flush and then ignore the results of the flush - that already happens. See 7.19.3 in the C99 Standard: "If the main
function returns to its original caller, or if the exit function is called, all open files are closed (hence all output streams are flushed) before program termination. Other paths to program termination, such as calling the abort function, need not close all files
properly."