I have a 79 240D. I started it up today and heard a whining sound under the hood.

When I shut the engine off, the whine continued. It was the starter motor continuing to run. I had to disconnect the battery cable to get it to stop. When I touched the cable back to the post, I got a big arc and the starter motor started (but wasn’t turning the engine?). Any ideas on how to trouble shoot this? Is the solenoid replaceable? Is a relay stuck? A new starter needed?
Thanks!