A method for controlling a drilling or cutting operation performed by a wireline tool downhole having a drill bit or cutting bit, comprising the steps of: - commencing a drilling or cutting operation in a downhole object, such as a casing or valve, - detecting vibrations in a tool housing produced during the drilling or cutting operation in the downhole object using a vibration sensor (10, 11, 12) being an accelerometer arranged on the tool housing, and - controlling the operation to terminate the operation when completion or failure of the operation has been detected, characterised in that the method comprises the steps of: - processing a vibration signal from the vibration sensor, during a first part of the drilling or cutting operation, to produce a reference frequency spectrum, - processing a vibration signal from the vibration sensor, during a second part of the drilling or cutting operation, to produce a real-time frequency spectrum, - comparing the real-time frequency spectrum to the reference frequency spectrum, and - calculating and detecting a completion or failure of the operation, such as a completion in which the casing has been cut into two casing sections or a failure in which the bit is stuck, based on the comparison of the real-time frequency spectrum and the reference frequency spectrum, wherein the step of calculating and detecting a completion of the operation comprises a step of calculating a centre of gravity of oscillation of an area of peaks in the frequency spectrum, which area is above a certain value and comparing that centre of gravity with a centre of gravity of an area of peaks in the reference frequency spectrum, which area is above the same certain value to determine a discrepancy between the two centres of gravity, and wherein the step of controlling the operation is based on the centre of gravity comparison. - commencing a drilling or cutting operation in a downhole object, such as a casing or valve, - detecting vibrations in a tool housing produced during the drilling or cutting operation in the downhole object using a vibration sensor (10, 11, 12) being an accelerometer arranged on the tool housing, and - controlling the operation to terminate the operation when completion or failure of the operation has been detected, - processing a vibration signal from the vibration sensor, during a first part of the drilling or cutting operation, to produce a reference frequency spectrum, - processing a vibration signal from the vibration sensor, during a second part of the drilling or cutting operation, to produce a real-time frequency spectrum, - comparing the real-time frequency spectrum to the reference frequency spectrum, and - calculating and detecting a completion or failure of the operation, such as a completion in which the casing has been cut into two casing sections or a failure in which the bit is stuck, based on the comparison of the real-time frequency spectrum and the reference frequency spectrum, wherein the step of calculating and detecting a completion of the operation comprises a step of calculating a centre of gravity of oscillation of an area of peaks in the frequency spectrum, which area is above a certain value and comparing that centre of gravity with a centre of gravity of an area of peaks in the reference frequency spectrum, which area is above the same certain value to determine a discrepancy between the two centres of gravity, and wherein the step of controlling the operation is based on the centre of gravity comparison.