Normal procedure was to leave the main air induction valve open until the engines had a chance to come to a full stop, this operation being so timed as to occur just prior to complete submergence. In the case of S-5, however, the chief of the boat, Gunner's Mate Percy Fox, the man responsible for operating this valve, was momentarily distracted. Noticing the mistake, he grabbed the valve lever and jerked hard, causing the valve to jam open. After considerable difficulty, the system valves in the other compartments were closed, but all efforts to secure the torpedo room valve met with failure. The abandoned torpedo room flooded, making the boat bow-heavy. An additional 80 long tons (81 t) of water in the motor room bilges caused her to settle on the bottom. It was now impossible to eject water from the torpedo room. An attempt was then made to pump out the motor room, but a gasket blew out and there were no means for repair. Lying 180 ft (55 m) on the bottom, the crew had little hope of being found, much less being rescued.
The crew reasoned that sufficient buoyancy in the after section could tilt the sub on her nose and extend the stern above the surface. The tilt would cause the water in the motor room to drain forward and increase buoyancy further. However, there was great risk involved because this would allow salt water into the battery room, which would generate deadly chlorine gas. They hoped to have enough time, after the water had entered, to close the watertight door before the gas could reach a dangerous level. After making preparations, air was applied to the after ballast and fuel tanks, blowing them dry. The stern began to rise and then shot to the surface. Men, floor plates, bilge water, and other loose objects fell through the length of the submarine. One man nearly drowned in the battery room, but was fished out, and the compartment door was sealed against the gas.
By tapping on the hull, it was determined that the stern extended about 17 ft (5.2 m) above the water. With inadequate tools, they took turns trying to cut a hole in the thick hull. After 36 hours, they had only succeeded in making a hole 3 in (76 mm) in diameter.
The steamship Alanthus detected the plight of the submarine. With additional assistance from the Panama Railway Company steamship General G. W. Goethals, a much larger hole was cut, and the entire crew was rescued.