He did what is right and just.
Yes, a church cannot employ people who are not in agreement with its teachings.
This does not just apply to Catholics. I know of a local Protestant church that fired a Sunday School teacher after learning she had convinced an old flame to leave his wife and shack-up with her instead.