Facebook, Microsoft, Twitter, and YouTube will work more closely together and with counter-terrorism officials to filter out extremist content from their websites.