Data only saves on esc, not when experiment ends normally

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 2022.2.5
Standard Standalone? (y/n) y

I only get any data from my experiment if I quit by pressing escape. When I press escape, I get the .psydat and both the .csv and .xlsx as expected. But when the script runs all the way through, there are no errors, but only the log file is output, even though all of the data boxes are checked.

I don’t know if it’s relevant, but I did follow this tutorial to order my stimuli for presentation. Is there code I need to add to the last routine to make sure that the datafiles get output?

Strangely, this is only a problem when my instructions block is enabled. When it is disabled, I get data no matter how I exit the script. The instructions block uses the regular method of presenting stimuli (using a list of csvs) while the test block uses the code from the pseudorandomization tutorial mentioned above. I don’t know if that mismatch is causing the problem somehow.

There are two code blocks in the instructions, one to show feedback after the practice trials, and one to repeat the practice trials if they didn’t reach 75% accuracy. I’m not sure how any of that would affect the data output at the end of the experiment, but if it would be helpful for me to post that code, I can.

Thanks for the help!