There have been a few instances in which boarding parties successfully attempted and captured submarines while on the high seas. During WWII, the British and American navies captured a number of U-boats. What would it have been like when attempting to take these vessels, knowing very well that they could dive or sink at any moment?
There were only a handful of U-Boats captured by the Allied powers during World War II. From what I can find, these included U-110, U-505, U-559, U-744, and U-570. Possibly more, but my brief search turned up no more.
The Germans captured only a single submarine, N37 which had surrendered after being immobilized and unable to dive.
In almost all cases, they weren't captured in some harrowing firefight, but because the crew had abandoned ship, and not properly scuttled the submarine, so Allied boarding parties were able to get on in time. The biggest challenge was getting and finding workable intelligence, or even saving the boat, before it sank, not fighting the crew. The simple fact is, if you are in a position to board a submarine, it is because she is so damaged that she can't get away anyways. In the case of U-570 for instance, she was immobilized and badly damaged, and the British apparently refused to rescue the crew unless they kept the U-Boat from sinking. With N37, similarly it was immobilized and the crew surrendered, thinking the boat was to damaged to remain afloat. A submarine wouldn't survive a surface attack from a destroyer if they refused to comply, and if they did attempt to dive (again, recall that they are badly damaged if they are in this situation) it is hard to see them attaining enough depth fast enough to evade pinpoint depth-charging. I can't find any accounts of a surfaced submarine in a position where a boarding party could have realistically entered, and the boat evading capture, or even making a concerted attempt.
So anyways, to sum it up, there was no real danger of the crew attempting to dive the boat, or of the crew attempting to defend their boat in a fire fight. The main danger present was the damage that the boat had sustained, or that the crew had intentionally inflicted in an attempt to scuttle it, and the resulting race against Davy Jones. In some cases the U-Boat couldn't be saved, like U-559, but they still got intelligence off it in time.