It shall be unlawful for the directing officer or the operator of any railroad train to direct the operation of or to operate the same in such a manner as to prevent the use of any street for purposes of travel for a period of time longer than five minutes; provided that this section shall not apply to a moving train or to one stopped because of an emergency or for repairs necessary before it can proceed safely.