Solidification of trapped liquid in rocks and crystals