My brake light switch under the brake pedal in the truck went bad. The brake lights were staying on intermittently.
As I recall it was a $10 part, but a pain to get to.
After the switch was replaced, it solved the problem of the brake lights staying on.
If your brake lights stay on while you are towing a trailer, you are probably dragging your trailer brakes. Trace