Your treasure is thrown overboard during the last phase of the round (phase 6). During Phase 5 (Upgrade Phase), your ship is at Pirate's Cove, where the hull is immediately restored to the circle with the skull symbol (5). So, you may still have up to 5 treasures at the end of that round.

Worst case scenario is if they knock you down to 4 hull. You do not get to immediately repair your hull, as it was not crippled (from my understanding), so you would only get to keep 4. You will never be forced to keep less than 4 treasure.