Ensure SystemExit is raised correctly when capturing warnings