On the control of a flexible beam colliding against an infinitely rigid and massive obstacle