Yes, that's the safe way to do it. Those hydraulic lines are under very high pressure (something like 2,000 psi!) when the tractor is running, enough so a leak can penetrate your skin, get in your eyes or otherwise cause severe injury. It's not safe to be fiddling with the connectors under those conditions. When it's shut down, you can de-pressurize the lines by moving the joystick.