Iraqi forces ended a hostage crisis in Baghdad on Thursday after they killed four remaining attackers who stormed a building occupied by a state-owned company, officials said.