rocks that are formed when molten rock cools