Error when running script twice in a row

1.Which seller did you purchase the product(s) from?
UCTTRONICS
2.The Model number of the product(s) you have purchased?
MT9F001 (UC397 RevA) Camera and UC-425 Rev C USB Shield
3.Which Platform are you using the product(s) on?
Raspberry Pi 4B
4.Which instruction are you following?
ArduCam GitHub / SDK documentation
5.Has your product ever worked properly?
Yes
6.What problems are you experiencing?
I can run the streaming demo just fine once. However, if I quit the script by entering “q” and try to run the script again, I get errors. See below for shell output:

First run:

~ $ sudo python Streaming_demo/ArduCam_Py_Demo.py Streaming_demo/MT9F001_RAW_8b_4384x3288_5fps.cfg

(‘color mode’, 0)
setFramerate not a function

Serial: AU3S-2027-0001
('Capture began, rtn_val = ', 0L)
fps: 3 /s

q

device close success!

Second run:

$ sudo python Streaming_demo/ArduCam_Py_Demo.py Streaming_demo/MT9F001_RAW_8b_4384x3288_5fps.cfg
(‘color mode’, 0)
setFramerate not a function

Serial: AU3S-2027-0001
('Capture began, rtn_val = ', 0L)
('Error capture image, rtn_val = ', 65318L)

q

device close success!
 

No images are saved in the second run and the script only works again after I reboot
the system. Any advice?
7.What attempts at troubleshooting have you already made?
Clearing cache, reading trhough script code
8.How would you like us to help you?
Offering solution