function profileSaveAsForCloseProfile(profile, fcn, peInstance)
    [fname, fpath] = uiputfile('*.xml', ...
        DAStudio.message('SystemArchitecture:ProfileDesigner:SaveAsTitle'),...
        profile.getName());
    if isequal(fname, 0) || isequal(fpath, 0)
        % User pressed cancel, abort saving
        return;
    end
    fullPath = fullfile(fpath, fname);
    
    % User picked a filename and path, check if the filename is
    % different from the profile name
    newName = strrep(fname, '.xml', '');
    prfName = profile.getName();
    if ~strcmp(newName, profile.getName())
        profileObj = systemcomposer.profile.Profile.find(prfName).getImpl;
        peInstance.updateMapOnProfileNameChange(prfName, newName);
    
        profileObj.setName(newName);
        pe.toolstrip.profileSave(profileObj, fullPath, fcn);
    
    else
        % Same name, just save the profile
        pe.toolstrip.profileSave(profile, fullPath, fcn);
    end
end