MPs were locked in the House of Commons for more than four hours and business suspended after a terror attack in Westminster.