Structural, mechanical and electronic properties of two-dimensional chlorine-terminated transition metal carbides and nitrides