Actually, as a point of information: offensive players are not only taught, they are encouraged, to hold in the endzone on a called intentional safety play. The longer they are able to hold, the longer the ball carrier has to scramble in the endzone. If the punter made any mistake, it was not holding out long enough. Although the risk of fumble is still there... if the punter fumbles, San Francisco has the opportunity to fall on it for a touchdown, in which case they would decline the holding penalty and take the touchdown.
What we saw last night is actually something of a white elephant play. The intentional safety is a rare play in football. Last time I saw one was a few years ago when Justin Blackmon from Oklahoma State ran 50 yards out the back of his own endzone at full speed on 4th down. Had he been caught and tackled, the other team would have gained possession there. Had he fumbled, they could have scored a touchdown. So the only option was to ensure the fastest guy on your team could make it out the back of the endzone without being caught.