TST: add test to verify if SystemExit is raised correctly.
- [x] closes https://github.com/pandas-dev/pandas/issues/18869
- [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature
- [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).


Thanks @HaruguchiKazuto!