Yes. It is perfectly legal for an employer to fire you for the sole reason that you are looking for a new job.