If it's someone else's meg and you just happen to go through that area while it is in the process of despawning there is nothing you can realistically do about that.
I dunno why they did this (and I was hoping it would be a part of the recent meg fix) but in season 8 they made it to where other people's megs won't target different boats and they just wander randomly till they despawn. Without the original target it becomes very unlikely that someone can take it out in time before it despawns.
If it's your meg it's just a matter of experience and being prepared.
"Pick your spots" a meg typically will spawn anywhere from 4 in game days all the way to 8+ in game days
This means keep track of your session time and plan to at least sail through open sea a bit so that area is less of an issue.
Example: I don't want to deal with a buggy meg and a galleon fight in between islands that are all close together. It might happen but I want to minimize that. So I pick my spots and plan my route around the in game times.
Nothing is ever a guarantee, all you are doing is increasing your chances of success, stuff can always go wrong and/or get chaotic.
That's why I enjoy it, it's a hunt, lots of planning and strategy in organic adventure.