I found the answer so I post it here for others with the same problem. The tutorial for having a live video preview in a GUI window uses
for blocking the execution of other programs. The output data is therefore written, when the GUI is already closed and this means that handles like a video-object are already deleted and the output data cannot get any information about this object because it does not exist anymore. By adding
in the CloseRequestFcn before any other command. The output data is written while the GUI is still open and therefore the objects still exist and are valid for the output function.