Yes, as Vincent suggested, having the workflow finish by itself would be the safest way to prevent video loss. This unfortunately requires some kind of external control over the Bonsai workflow, which you can do through OSC, but there are 2 more "unconventional" ways which might work through MATLAB (although any of them requires investigation):
1. pipe a text input through standard in: Bonsai supports reading lines from the "console" standard input using the ReadLine source. If you had a way to pipe a standard input stream from matlab into the process you create, then you could write a line into the stream and use that event to stop Bonsai. Of course, this would also be a direct line of communication to pass in all kinds of other data. Incidentally WriteLine would have the same effect going the other way if you found a way to redirect the standard output.
2. call Bonsai direct from MATLAB: incidentally the previous link also points out the interesting fact that MATLAB can just call a .NET library and/or applications directly. This means you would be able to simply instantiate a Bonsai workflow straight in MATLAB and simply pass the config data and potentially even call inputs/functions directly without having to spawn a subprocess.
These are just food for thought for possible things, there is definitely room to have a more seamless integration between Bonsai and MATLAB but would require a bit of work.