Hello my name is Sam, welcome to Just Answer.
What has happened is the ignition housing is broken. The broken piece jammes up the ignition switch causing the ignition to stay in the on position.
To stop the engine from running, pull the fuel pump fuse. To keep the battery from draining, disconnect the negative battery cable after you pull the fuel pump fuse.
BMW Master technician
BMW S.T.E.P. graduate, 10 years BMW dealership experience