Ooh!
I've had the Ship stuck "Glitch" many times...
When Porting, I suggest asking ALL Gunners and Repair Crew to leave their tasks a few moments before you reach Port... I've found this minimizes the "risk" of a pirate getting stuck on your ship and subsequently disconnecting as it sinks.
Just another odd thing I noticed, when Porting, Dancing a Jig seems to help myself and many others from disconnecting, also making sure the Loot/Cargo Display is closed.
Hope these little tips assist, dunno WHY they help, but they certainly do I find.
Cheers!