If it won't turn off with the key then you have the wrong switch fitted
There are two things that can stop the engine
1) the M ( Magneto ) terminal gets shorted to the G ( Ground ) terminal.
2) the fuel solenoid wire ( can be a couple of different terminals ) looses battery voltage .
The cranking circuit goes from the S terminal on the key switch to the PTO switch to the Parking Brake switch to the trigger wire on the solenoid .
That supplies the power to switch the solenoid.
But remember the solenoid also needs a ground connection of some sort to complete the circuit .
The wiring diagram should be in the parts book and the parts book is a free download from Husqvarna .