All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger. We ask Allaah to exalt his mention as well as that of his family and all his companions.
The question is not clear. Anyway, our view is that it is an obligation on the Imaam to open the mosque for the five daily prayers if there are people who come to the mosque to pray. Not opening the mosque for the five daily prayers is contrary to the purpose for which the mosque was built, and it is preventing people from the mention of Allaah. Allaah says (which means): {And who are more unjust than those who prevent the name of Allaah from being mentioned [i.e. praised] in His mosques and strive toward their destruction.}[Quran 2:114].
Shaykh Al-Islam Ibn Taymiyyah said: 'It is not permissible to close the mosques and stop the function for which they have been built.'
The jurists stated that whoever offers a mosque as an endowment and sets a condition that only a specified group of people are allowed to pray in it, his condition is not taken into account and it is permissible for anyone to enter and pray in it.
In principle a mosque should be opened for the five daily prayers and it is not permissible to close it. If the Imaam is not able to fulfil the responsibility of leading people in the five daily prayers, then he has to leave his post as an Imaam for whoever is able to fulfil his responsibilities. If he refuses, you may take his matter to an Islamic foundation in your country or to an authority which is able to oblige him to fulfil his religious obligations.
Finally, we draw your attention that if it is feared to degrade the mosque or lose its assets if it is left open, then it is permissible for the Imaam to close outside prayer times in order to protect its assets. This is the view of the jurists and this ruling applies for periods other than prayer times when it is feared that some damage could occur. But it should not be closed when there is no fear of any damage or harm.
Allaah knows best.