Court allows ex-president Musharraf to leave Pakistan