A hydraulic tool (100; 1400) comprising: a tool head (114; 1418) comprising a first part of the hydraulic tool and a second part of the hydraulic tool, the first part comprising a plurality of jaws, which are operable to open and close for performing work on a workpiece and the second part comprising a frame of the tool head; a moveable piston coupled to the tool head; a motor operable to drive the moveable piston to close the plurality of jaws to a closed position at which the work on the workpiece is completed; a position sensor including a first sensor portion on the first part of the hydraulic tool and a second sensor portion on the second part of the hydraulic tool, characterized in that the position sensor is configured to detect when the plurality of jaws are at the closed position and responsively generate a sensor signal indicating that the plurality of jaws are at the closed position; wherein the first part of the hydraulic tool is configured to move relative to the second part of the hydraulic tool while the plurality of jaws open and close, wherein the first part of the hydraulic tool is at a predetermined location relative to the second part of the hydraulic tool when the plurality of jaws are in the closed position, and wherein the first sensor portion is configured to actuate the second sensor portion responsive to the first part of the hydraulic tool reaching the predetermined location relative to the second part of the hydraulic tool; wherein the hydraulic tool further comprises a controller configured to receive the sensor signal from the position sensor, wherein the controller is configured to operate the motor based on the sensor signal that the controller receives from the position sensor. a tool head (114; 1418) comprising a first part of the hydraulic tool and a second part of the hydraulic tool, the first part comprising a plurality of jaws, which are operable to open and close for performing work on a workpiece and the second part comprising a frame of the tool head; a moveable piston coupled to the tool head; a motor operable to drive the moveable piston to close the plurality of jaws to a closed position at which the work on the workpiece is completed; a position sensor including a first sensor portion on the first part of the hydraulic tool and a second sensor portion on the second part of the hydraulic tool, characterized in that the position sensor is configured to detect when the plurality of jaws are at the closed position and responsively generate a sensor signal indicating that the plurality of jaws are at the closed position; wherein the first part of the hydraulic tool is configured to move relative to the second part of the hydraulic tool while the plurality of jaws open and close, wherein the first part of the hydraulic tool is at a predetermined location relative to the second part of the hydraulic tool when the plurality of jaws are in the closed position, and wherein the first sensor portion is configured to actuate the second sensor portion responsive to the first part of the hydraulic tool reaching the predetermined location relative to the second part of the hydraulic tool; wherein the hydraulic tool further comprises a controller configured to receive the sensor signal from the position sensor, wherein the controller is configured to operate the motor based on the sensor signal that the controller receives from the position sensor.