There are a couple ways of handling this depending on your program structure, and if you're using a single program or an EG Process Flow. The ABORT function alone doesn't stop all SAS processes unless you utilize the RETURN argument as well.
Assuming you've tried that with no success, then it has to be something in the way your code is executing. Without seeing the specific environment, my suggestion would be to wrap the file output code (or any other code you don't want to run in the same .SAS file) inside a MACRO to check for errors. SAS provides the &SYSCC and &SYSERR environment variables already for you to compare to.
If you want to discuss alternatives, then I would need to see how your environment is structured and executed in order to give a better diagnosis.
ABORT: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/p0hp2evpgqvfsfn1u223hh9ubv3g.htm
SYSCC: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p11nt7mv7k9hl4n1x9zwkralgq1b.htm
SYSERR: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n1wrevo4roqsnxn1fbd9yezxvv9k.htm
--
AJ