A slewing-type working machine comprising: a lower travel body; an upper slewing body mounted on the lower travel body so as to be able to be slewed; a hydraulic motor which is a drive source for slewing the upper slewing body; a slewing electric motor connected to an output shaft of the hydraulic motor; a hydraulic pump which is a supply source for supplying to the hydraulic motor hydraulic oil for operating the hydraulic motor; a slewing operation device to which an operation is applied to command slew driving and slew braking of the upper slewing body; a control valve which is operated to control supply of hydraulic oil to the hydraulic motor and discharge of hydraulic oil from the hydraulic motor on the basis of the operation applied to the slewing operation device; a brake valve which is connected to motor both-side lines (14, 15) connected to both sides of the hydraulic motor respectively to make a hydraulic brake action; a communication valve (26, 27) configured to be switched between an open position for bringing a line which is one of the motor both-side lines (14, 15) and is connected to an outlet side of the hydraulic motor into direct communication with a tank or a line which is the other of the motor both-side lines (14, 15) and is connected to an inlet side of the hydraulic motor, so as to bypass the control valve, and a close position for blocking the communication; a communication-valve-switching command output section which outputs a communication-valve-switching command for switching the position of the communication valve (26, 27); a torque command output section which outputs a torque command for specifying a torque of the slewing electric motor; characterized by an abnormal-switching detection section which detects occurrence of an abnormal switching in the communication valve (26, 27), wherein the torque command output section performs: (i) determining, as a target value, a pressure which would be generated in the hydraulic motor if the communication valve (26, 27) was absent, or a torque determined based on the pressure, based on an operation state of the slewing operation device and a slewing state of the upper slewing body; (ii) determining, as an actual value, a pressure actually generated in the hydraulic motor or a torque determined based on the pressure; and (iii) outputting the torque command for specifying the torque of the slewing electric motor on the basis of a value obtained by subtracting the actual value from the target value. a lower travel body; an upper slewing body mounted on the lower travel body so as to be able to be slewed; a hydraulic motor which is a drive source for slewing the upper slewing body; a slewing electric motor connected to an output shaft of the hydraulic motor; a hydraulic pump which is a supply source for supplying to the hydraulic motor hydraulic oil for operating the hydraulic motor; a slewing operation device to which an operation is applied to command slew driving and slew braking of the upper slewing body; a control valve which is operated to control supply of hydraulic oil to the hydraulic motor and discharge of hydraulic oil from the hydraulic motor on the basis of the operation applied to the slewing operation device; a brake valve which is connected to motor both-side lines (14, 15) connected to both sides of the hydraulic motor respectively to make a hydraulic brake action; a communication valve (26, 27) configured to be switched between an open position for bringing a line which is one of the motor both-side lines (14, 15) and is connected to an outlet side of the hydraulic motor into direct communication with a tank or a line which is the other of the motor both-side lines (14, 15) and is connected to an inlet side of the hydraulic motor, so as to bypass the control valve, and a close position for blocking the communication; a communication-valve-switching command output section which outputs a communication-valve-switching command for switching the position of the communication valve (26, 27); a torque command output section which outputs a torque command for specifying a torque of the slewing electric motor; an abnormal-switching detection section which detects occurrence of an abnormal switching in the communication valve (26, 27), wherein the torque command output section performs: (i) determining, as a target value, a pressure which would be generated in the hydraulic motor if the communication valve (26, 27) was absent, or a torque determined based on the pressure, based on an operation state of the slewing operation device and a slewing state of the upper slewing body; (ii) determining, as an actual value, a pressure actually generated in the hydraulic motor or a torque determined based on the pressure; and (iii) outputting the torque command for specifying the torque of the slewing electric motor on the basis of a value obtained by subtracting the actual value from the target value. (i) determining, as a target value, a pressure which would be generated in the hydraulic motor if the communication valve (26, 27) was absent, or a torque determined based on the pressure, based on an operation state of the slewing operation device and a slewing state of the upper slewing body; (ii) determining, as an actual value, a pressure actually generated in the hydraulic motor or a torque determined based on the pressure; and (iii) outputting the torque command for specifying the torque of the slewing electric motor on the basis of a value obtained by subtracting the actual value from the target value.