The procedure you refer to is usually called “desacralization.” The Church’s Code of Canon Law specifies, “If a church cannot be used in any way for divine worship and there is no possibility of repairing it, the diocesan bishop can relegate it to profane but not sordid use” (CIC 1222). For example, a defunct church building could be turned into a museum or cafe provided that it was not intended to promote scandalous behavior.
The Code also says, “The eucharistic celebration is to be carried out in a sacred place unless in a particular case necessity requires otherwise; in such a case the celebration must be done in a decent place” (CIC 932.1). Therefore, as long as the desacralized church remains “decent,” then it can be an acceptable place to celebrate Mass if a particular case of necessity requires it.
For example, if a group of Catholic pilgrims in a foreign country wanted to celebrate Mass but no active Catholic church was near them, they may choose to gather in a building that was once a Catholic church but has now been desacralized.