Ensure spool file is closed on invalid spool type