Breaking bad habit

Okay... So my son is 9 months old and I've been watching his year old cousin. Well my son is really content, never really cries unless hes hungry or tired or needs his diaper changed. He can keep himself entertained with his toys if I need to run to the bathroom or switch the laundry. But his cousin cries constantly and throws a fit every time I run to the bathroom or go behind a baby gate, starting this morning my son started doing the same thing. I don't know how to teach him not to do that now when he used to never do it before but his cousin does it all day every day.

Is there anything I can do?