Retrieving log files from NixTest VM after running test

I have a pkgs.nixosTest that runs on a single machine with the following testScript:

testScript = ''
    machine.succeed("some program that creates a log file", timeout=300)

When the test completes successfully, the log gets copied to the store and I can access it after building the test. However, if it times out, it appears that machine dies before it can copy out the log. I have also tried the following:

status, _ = machine.execute("some program that creates a log file", timeout=300)
if status:
  raise Exception(f"Program failed with status {status}")

However, as before, the issue is that the log won’t be copied if the operation times out.

What is the “correct” way to copy logs off of the machine before it dies?