Sounds like you’re having a pretty tough time with that
Exercise will have the immediate effect of increasing your insulin sensitivity. A basal of 40 units morning and evening is already pretty high and you could find needs adjusting (reducing) by more than 5 units on a day that you exercise. (Exercise regularly and you will need even less)
It’s hard to offer much advice without understanding a bit more about your activity - so how long did you exercise for? How hard did you work out (what was the level of intensity) etc. All of this impacts on what you would ordinarily expect with your activity.
I was a bit confused by your comment ‘I waited 5 hours before I took my insulin’ - do you mean you waited 5 hrs before you bolused for the meal, or was that when you had your ‘morning’ basal? (Apologies for being a bit dense!)
To help you out a bit, for an hour of aerobic exercise you can pretty much expect to burn through 60g carbohydrate. In order not to suffer with low blood sugars later on in the day or that night, (and assuming your body is not adapted to running super low carb) then you’re going to have to expect to at least replace that amount of energy.
When you exercise, your muscles and liver become depleted of glucose. They have to replace this by drawing glucose out of the blood stream. If you burnt more than 60g of carbs during your exercise, then there is every chance you will suffer a low blood glucose level at some point after your activity. The opportunity for this can be exacerbated by taking a large dose of insulin, as it enables the muscles to take up glucose much more readily (so you can see a rapid blood glucose fall).
Have you considered getting a insulin pump?
Unfortunately there is no magic answer for you - it’s just going to take a bit of trial and error, lots of testing and note taking. Before long you’ll start to see a pattern and be able to work out a strategy that works though, so keep it up!