Greetings, welcome to the Forums.
This may be a Dracaena or a Yucca, it's hard to tell as it is in quite bad shape. The plant seems to be etiolated due to insufficient light, and it may be suffering from nutrient deficiencies as well. Etiolation causes stems to elongate excessively and weaken. Usually it would be easy to cut off the dangling stem and re-root it, but if the cutting is not healthy it becomes more difficult.
Your best bet is as follows. Cut off the dangling stem and plant it in well-draining potting soil. The hope will be to root it as a separate plant. Also re-pot the base of the plant in with some fresh soil as well. It may likely resprout with new growth Needless to say, both plants should be in containers with drainage holes. Now move both plants into brighter light than they were growing previously. Do this now in Winter when the light is less intense to prevent leaf scorching from sudden change. Besides watering you will also begin a fertilizing regimen use a complete, liquid fertilizer. The first application should be light. After you see active growth, bring it up to the product's recommended dose and frequency.