public void destroyRoom(JID alternateJID, String password, String reason) {
        Collection<MUCOccupant> removedOccupants = new CopyOnWriteArrayList<>();

        fmucHandler.stop();

        // Remove each occupant from a copy of the list of occupants (to prevent ConcurrentModificationException).
        for (MUCOccupant leavingOccupant : getOccupants()) {
            if (leavingOccupant != null) {
                // Add the removed occupant to the list of removed occupants. We are keeping a
                // list of removed occupants to process later outside the lock.
                removedOccupants.add(leavingOccupant);
            }
        }
        endTime = System.currentTimeMillis();
        // Set that the room has been destroyed
        isDestroyed = true;
        // Removes the room from the list of rooms hosted in the service
        mucService.removeChatRoom(name);

        // Send an unavailable presence to each removed occupant
        for (MUCOccupant removedOccupant : removedOccupants) {
            try {
                // Send a presence stanza of type "unavailable" to the occupant
                final Presence presence = createPresence(Presence.Type.unavailable);
                presence.setFrom(removedOccupant.getOccupantJID());

                // A fragment containing the x-extension for room destruction.
                final Element fragment = presence.addChildElement("x","http://jabber.org/protocol/muc#user");
                final Element item = fragment.addElement("item");
                item.addAttribute("affiliation", "none");
                item.addAttribute("role", "none");
                final Element destroy = fragment.addElement("destroy");
                if (alternateJID != null) {
                    destroy.addAttribute("jid", alternateJID.toString());
                }
                if (password != null) {
                    destroy.addElement("password").setText(password);
                }
                if (reason != null && !reason.isBlank()) {
                    destroy.addElement("reason").setText(reason.trim());
                }

                // Not needed to create a defensive copy of the stanza. It's not used anywhere else.
                removedOccupant.send(presence);
                removeOccupant(removedOccupant);
            }
            catch (Exception e) {
                Log.error("An exception occurred while tyring to inform occupant '{}' that room '{}' was destroyed.", removedOccupant, name, e);
            }
        }

        // Remove the room from the DB if the room was persistent
        MUCPersistenceManager.deleteFromDB(this, alternateJID, reason);
        // Remove the history of the room from memory (preventing it to pop up in a new room by the same name).
        roomHistory.purge();
        // If we are not preserving room history on deletion, fire event to clear chat room history
        if(!preserveHistOnRoomDeletion) {
            MUCEventDispatcher.roomClearChatHistory(getID(), getJID());
        }
        // Fire event that the room has been destroyed
        MUCEventDispatcher.roomDestroyed(getID(), getJID());
    }
Destroys the room. Each occupant will be removed and will receive a presence stanza of type
"unavailable" whose "from" attribute will be the occupant's nickname that the user knows he
or she has been removed from the room.

@param alternateJID an optional alternate JID. Commonly used to provide a replacement room. (can be {@code null})
@param password an optional password to be used for accessing the replacement room (can be {@code null}).
@param reason an optional reason why the room was destroyed (can be {@code null}).
xmppserver/src/main/java/org/jivesoftware/openfire/muc/MUCRoom.java