Thank you for your answer!
I found a problem in the meantime. The error was not in the code but in the external signals coming from PLC which explains why this happened only when starting robot externally. The cycle start external signal remained used in another part of the PLC program and although we turned it off in the sequence for starting a robot, another part of the PLC program turned it on again and hold it like that.
Sorry if this post turned out to be spam. If moderators want to, they can delete it.