We consider a vibrating string that is fixed at one end with Neumann control action at the other end. We investigate the optimal control problem of steering this system from given initial data to rest, in time T, by minimizing an objective functional that is the convex sum of the L2-norm of the control and of a boundary Neumann tracking term.We provide an explicit solution of this optimal control problem, showing that if the weight of the tracking term is positive, then the optimal control action is concentrated at the beginning and at the end of the time interval, and in-between it decays exponentially. We show that the optimal control can actually be written in that case as the sum of an exponentially decaying term and of an exponentially increasing term. This implies that, if the time T is large, then the optimal trajectory approximately consists of three arcs, where the first and the third short-time arcs are transient arcs, and in the middle arc the optimal control and the corresponding state are exponentially close to 0. This is an example of a turnpike phenomenon for a problem of optimal boundary control. If T=+∞ (infinite time horizon problem), then only the exponentially decaying component of the control remains, and the norms of the optimal control action and of the optimal state decay exponentially in time. In contrast to this situation, if the weight of the tracking term is zero and only the control cost is minimized, then the optimal control is distributed uniformly along the whole interval [0,T] and coincides with the control given by the Hilbert Uniqueness Method.In addition, we establish a similarity theorem stating that, for every T>0, there exists an appropriate weight λ<1 for which the optimal solutions of the corresponding finite horizon optimal control problem and of the infinite horizon optimal control problem coincide along the first part of the time interval [0,2]. We also discuss the turnpike phenomenon from the perspective of a general framework with a strongly continuous semi-group.