I once had a guppy that I kept all himself before I knew anything about fish. He didn't die, but he ended up becoming neurotic. All he'd do was go up and down and up down and I could count his laps until I got to a hundred or so and he'd still keep on going.
However, in the case of your molly, there may be causes of death other than just lonliness--mollies are not strictly schooling fish, so if there was another molly (or even just other fish) lonliness may not be the cause of death. I have successfully kept mollies and/or guppies alone with other species of fish to no ill effect.
One of the most common causes of death among aquarium fishes is fatty degeneration of the internal organs. Fish will die without any external signs of disease. It may sometimes be caused by incorrect feeding--too many foodstuffs containing excessive fats and carbohydrates in comparison to proteins are given. It takes a very slow course and doesn't present many symptoms, but it will finally cause the death of the fish.