Switch to use contextlib.ExitStack for cleaner run context