24 V transistor switch acting strangely
A brake is an electrogmagnetic component. It has a resistance but is mainly inductive.
When the brake is turned off the current will tend to continue flowing and a spike or back electromotive force will appear which will overheat or destroy the transistor after it is blocked.
Adding a freewheeling or flyback diode will allow current flow in this condition and protect the transistor: