Long Island College Hospital in Cobble Hill will close its obstetrics and gynecology departments and sell two buildings in an effort to ward off bankruptcy.