Issue 10344 Exiting _Dmain should flush all FILE*s and return nonzero on failure

Changed according to feedback from Walter and Andrei:

* Only flushing stdout (crt will take care of the other streams, ignoring the error code)
* Print error to stderr (ignore any error code)
* Change return code from main to non-zero (iff currently zero)