When the first mosque for which he collected the funds has been completed and no longer needs the money, whatever funds remain should be spent on building other mosques. The additional facilities that go with a mosque, such as a library, washrooms and the like, should also be built, as the people of knowledge have written about this in explicit terms in Kitab al-Waqf.
Furthermore, this mosque is also of the same kind as the mosque for which he gave the money in charity. It is also a known fact that charitable donors intend to spend their surplus wealth on building a house of Allah the Most High. If there is no mosque in need, this money may also be spent for the benefit of the Muslims and on public welfare, such as building schools, constructing roads and spending on the poor. And Allah knows best.
Reference: Ibn Baz: Majmu’ al-Fatawa wa al-Maqalat: 14/20