Glycogen depletion, post-brief-ride recovery, and diet adjustment
This is most likely a mixture of fuelling and trying to do too much too soon.

It sounds like you routinely eat a fairly low carb diet, which is not in itself a bad thing, but will mean that it's unlikely your glycogen stores are ever more than partially filled.  This is not a problem at all during low intensity exercise, but when exercising at high intensity for a prolonged duration (racing yourself for 40km), its a recipe for poor performance and and bonking/hitting the wall.  When you fully deplete your glycogen stores in this manner it is normal to take several extra days for recovery.

In terms of your choice of workout, it is also likely you are creating a training load that is far too high for you to handle.  Going flat out for 40km is something an experienced cyclist might do once a week at most - and even then not for a prolonged period.  And after completing such an effort, they would expect to feel sore and sluggish for several days afterwards and limit themselves to low intensity riding.

Assuming you want to continue trying to test yourself over 40km, you might like to consider having much more structure in your riding.  As an example you could do something like the following:

Week1


30km ride with 15km hard
40km easy
rest day
30km ride with 15km hard
rest day
60km easy
rest day


Week2


30km ride with 15km hard
rest day
60km easy
rest day
rest day
40km max effort
rest day


This still gives you an average of a ride every other day.  It includes some shorter and harder efforts which  whilst very hard in their own way, will not create nearly as much training load.  And you have some longer rides to build your engine.