Abdul Khalid Ibrahim has dismissed his sacking from PKR as "flawed and illegal", insisting that he will stay on as Selangor menteri besar.