To be honest, I don't understand exactly the problems, but I try to give some guideline and hope you can use the idea to fix your problems.
What you need is a so called 'state machine'.
I think (according to your problem) that you have 6 states:
0 Idle (no sequence)
1 One LED on
2 Two LEDs on
3 Three LEDs on
4 Four LEDs on
5 No LEDs on
For this you can ...
Consider a Phase Locked Loop (PLL) to synchronize your 40x 25ms pulses with your 1pps RTC.
If you need 25ms/pulse to get 1rpm, that's 2400ppm or 1pulse/0.025ms=40pps. If you get a 1pps pulse out of the RTC, you can use it to discipline your timing. https://www.romanblack.com/one_sec.htm is a good reference.
The basic trick is to keep track of the mismatch ...