Salem to P-town looks like 45 nm. My half dozen trips across Mass Bay had the wind all over the place and we found ourselves choosing a destination based on the wind direction. Scituate turned into P-town on at least 2 occasions.
Unless you want to go to P-town (sounds like you do) you might otherwise choose your intermediate stop based on the wind direction and velocity. Our last trip had us turning around to spend an extra day at Manchester-by-the-Sea when we encountered gusts to 47 kts out of the NW. My wife noticed that even the lobstermen were returning to port and so did we.
P-town to the canal entrance is about 22 nm and you might find the wind on the nose. We've also stayed over in P-town awaiting better weather (different trip) on the way to the canal. Your estimate of 5 hours sounds right, even if you are motoring.
The Boston option may take more time than you expect, especially if you are really going to check out the harbor. Salem-Boston-P-town looks like about 60 nm and would mean at least 12 hours sailing plus whatever time you take to explore Boston Harbor. It's doable, but sounds more like work than fun. If you want to do Boston, you might allow a whole day to a cursory check of the harbor and the outer islands, ending up in Scituate for the night.
In the end, the weatherman may be choosing your course. Hope you are allowing for such contingencies.