I did some testing for Han's behavior in Fort Joy. Thought I'd leave my conclusions here in case anyone else is trying to figure the little rascal out.
(PERVASIVE SPOILERS for Fort Joy)
The main problem is that sometimes when arriving for the first time at that interior dock where Han is usually located, I found that Han, his boat, and the two associated magisters (Goa and Carin) were simply missing. This is particularly annoying if you wanted to fight those magisters to get Carin's unique shield.
Looking around online yielded lots of conflicting views about why this might be happening – if it is on a timer and how the timer might have become activated, etc. So I decided to try to figure it out. After a lot of pain and grief testing different variables, here's what I came up with:
(1) There is an invisible north-south line on the external Fort Joy map, extending through the middle of the harbor area and then along the fort wall near the drawbridge, and south from there. If you cross that line, moving east toward the Hollow Marshes, Han & co. will immediately disappear from the inside dock (regardless of whether or not you have met him yet). It's not actually based on what named "area" of the map you enter, it is just how far east you go.
I think the reason this catches a lot of people is because some of us chase after Gawin into the harbor area during the teleporter quest. This is still OK as long as you don't go too far into the harbor – it depends on where exactly Gawin dies and how far you have to advance in order to loot him. If you go to the middle of the line of silent monks in the harbor, that is too far. But if you only go to the stairs just before the line of monks, that is OK.
(Like I said, it took a lot of grief to figure that out – but you can test it yourself by going out there, saving, running back through the beach cave entrance to check on Han, loading and moving a bit further east, etc. It is also possible to sneak out to the drawbridge and test it there, or to sneak past Orivand and test it at the southern exit. In the southern route behind Orivand, you can actually enter the very edge of the Hollow Marsh area, then teleport back, and still find Han in place, as long as you don't go too far east.) So, crossing that invisible vertical line on the map is the main thing.
I can also confirm:
(2) If you approach Han to the point where you can see him and overhear his quarrel with the magisters, but then turn around and leave the area without speaking to them, then Han will also immediately disappear. This makes sense I guess, since they aren't going to stand there arguing forever. (This is very easy to test; just get to where you can barely overhear Han talking to the magisters, then turn around and go down the stairs right nearby, then come back up and he will be gone.)
Finally:
(3) As best as I can tell, there does not seem to be any kind of timer involved in it. This surprised me, since after talking with Han he tells you to hurry and he won't wait around forever, etc. My first thought was that I had inadvertently started a timer during my early explorations of the ghetto, for example by going through Withermoor's hatch or into Orivand's quarters, long before meeting Han, and thus he had already left before I got to him. So my initial tests involved, e.g., going up to Orivand's room and then coming back to stand around in the ghetto (just letting the game run while doing other work, since that's the only way I could find to advance the clock).
None of these timer tests resulted in Han leaving, even after I stood around for an entire two days of in-game time (ten hours of real time), which is much longer than it takes to actually finish Fort Joy. Finally I went in there and actually talked to Han, asked him to wait for me, then teleported out and stood around in the ghetto. Han was still waiting with his boat two full days later.
I saw another comment above that someone had looked at the game files and found a timer on Han, but no start conditions for it. So possibly a timer was there at some point but then it was removed? In any case I'm 99% sure that currently there is not a timer causing him to leave. Which again, was very unexpected based on his dialogue etc.
Bottom line: Han's vanishing act seems to result from moving too far east on the external map, or else from approaching too close to him and then leaving the level without talking to him.