Police officers who fail background checks will be automatically sacked from next month to close a "glaring gap" in the law.