duration on metro lib

You aren't really controlling the pulse duration, you're just turning the pulse off at a fixed interval after you turned it off last time - but not accounting for processing delays.

Given what you're trying to achieve, I suggest you simply use the technique demonstrated in the 'blink without delay' example sketch to start the pulse at regular intervals, and end the pulse after the length exceeds your desired duration.

Also, if keeping strict phase is important to you, I suggest that when you detect the interval has passed you update the lastTime value by incrementing it, rather than by setting it to the current time:

if(millis() - lastTime >= period)
{
    lastTime += period;
    ... other stuff ...
}