@nahtheguy
Emergent and random roaming skeleton ships will dive back into the ocean when their target has been taken care of. If one spawns on you and sinks you, it will leave even if a second ship is still engaging it. Random roaming ships will do this too if you engage it and your ship sinks.
This isn't the only thing that will cause them to dive into the ocean again though. I've noticed that all ships on the map will dive into the ocean despawning right before a ship cloud becomes active. The ship fleet won't exist during the same times that emergent and roaming ships are active and vice versa.
One thing you can do to still end up with the treasure on a skeleton ship even if it runs, is to pick up the treasure on the ship. When the ship despawns, any treasure not touched will despawn with it, but any treasure that has been touched even if it's still on their ship, will remain when the ship disappears.