Does that mean you're "illegal" in the mean time?
Because you can't even apply until like 60 days before your visa expires, right?
You can apply 28 days before you qualify for ILR, which is usually 28 days before your visa expires (but can be different depending on what visa you have).
No, you aren't illegal - your current visa status is simply extended while the ILR application is processing.
The only way you would become illegal is if your visa had expired before you applied for ILR, or if your ILR was refused... in which case you would only have a certain number of days to either apply for a different visa or leave the UK.