First choice is out as opening hours are 9 AM to 5 PM (Canal's website).
With second choice you'd have only five hours, and while it's not a huge airport I remember it took me around one hour to go through passport control after exiting the plane and obviously you need to come there some time before the return flight, which leaves you with 2-3 hours outside of the airport.
Canal lies around 36 km from the airport, so assuming you take taxi both ways you'll have maybe one hour in the canal itself, where you'd still have to buy the tickets to see anything.
I think it's not enough unless you'll be satisfied with a quick look (but it's better to stay there for at least one-two hours to see the ships passing by and locks in operation). And it would be risky. If you had 7-8 hours, I think it would be doable.