The department shall have the authority to close temporarily any part or all of a highway. Whenever the department closes such highway or part thereof, the department or its contractor shall erect, at both ends of the portion of the highway so closed, suitable barricades, fences, or other enclosures and shall post signs warning the public that the highway is closed by authority of law. Such barricades, fences, enclosures, and signs shall serve as notice to the public that such highway is unsafe and that anyone entering such closed highway, without the permission or consent of the department, does so at his own peril. The department, if it deems it advisable, may permit the public use of a highway undergoing construction, repair, or maintenance in lieu of a detour route and is authorized to regulate, limit, or control traffic thereon.