The movement effect of Ghostly starts at the beginning of the ship’s first movement segment and stops at the end of the ship’s very last segment (a stern turn is treated as the last segment; a windcatcher flip is treated as the first).
The movement effect does not apply for the entire duration of a move action, such as during free actions generated during or because of that move action. In other words, if the Ghostly ship’s last movement segment ends with it overlapping terrain, it must deal with that terrain before it can use other free actions, like a captain. It’ll take damage from an iceberg before shooting, or it’ll get pulled into the fog bank preventing it from shooting at all.
Historical Fun Fact: Way back when Crimson Coast first came out, Ghostly and the terrain-ignoring ability (only Agustin Covas at the time) were both allowed to ignore terrain for the entire move action, including for a captain’s shooting. Covas on El Neptuno could do a really cool hit-and-fade attack from within fog banks, with no good way to defend against it other than staying out of its 2L range. That obviously created some issues, so it got shut down relatively quickly.