Closing the pitlane just means it's those that pitted just before the SC that benefit. Other drivers can end up being left out on older tyres and are then forced to bit after the SC ends when the field has bunched up.
It is in my view just part of racing, and there isn't really a need to "fix" it. However, if you were trying to nullify the advantage that could be gained during an VSC or SC period, you could do one or many of the following:
- Introduce a minimum pitstop time for stops taken during a VSC or SC period. This would probably need to be calibrated for each circuit, but the idea is to nullify the advantage of pitting while cars are circulating slower. The cars are given a lap delta to hit during the VSC/SC so it would probably be quite easy to work out what the pit delta needs to be.
- During an SC specifically, drivers lose their advantage because they all bunch up behind the SC (or possibly have to do a standing start). You could record the interval between drivers at the end of the previous lap before the SC, and then add that to everyone's race time. For example, P2 is 6 seconds behind P1 when the SC is called, so they get 6 seconds added to their race time. Sure it seems "fair", but it would make for an awful spectacle after the restart as suddenly none of the on track battles really matter, drivers are basically racing the clock at this point, the driver in P2 could take the lead and still not win.
- As an alternative perhaps a staggered standing start could be used. Drivers all line up for a standing restart, but they each get their own start signal from the cockpit, timed based on the gap they had to the driver ahead when the SC came out. In the previous example, P1 goes first and then 6 seconds later P2 starts the race, and it continues down the grid until all cars are on their way. This is probably the only way to "restore" the race close to how it was before the SC came out, but it's probably still going to have it's issues as the starts will vary to a certain extent.
If you didn't like any of those ideas it's because they're all pretty rubbish really. It's not possible to "fix" the SC, it is what it is and it's part of racing. However, I do personally prefer the VSC as it means the race isn't completely reset, and I do wonder if it could have been used today for the Ocon incident. When they first implemented the VSC they used it a lot, but then it's almost as if they realised it doesn't create as much drama/jeopardy so they reverted to using the full SC.