The world's first YMCA is to close in the New Year after being sold to a developer of luxury flats and hotels.