The problem is that you’re not providing the appropriate residue type name. The issue is that terminal residue types are “patched” to add the appropriate atoms for the terminal behavior. Take a look at the output PDBs, specifically the energy table at the end. Notice that the names of the terminal residues aren’t just “ALA”, but are “ALA_p:NtermProteinFull” or “ALA_p:CtermProteinFull”. the “_p:” means it’s a patched residue type, and the “NtermProteinFull” and “CtermProteinFull” are the patch types applied to the residue. The full string, with the patch designator and patch type string is what you need to give to the new_res parameter of MutateResidue.
That said, the fact that you’re getting a segmentation fault is a bug. At the very least it should be giving you a (hopefully helpful) error message.