My BMW 04 745Li will not start all the time on 1st try and shut down on its own. on 2004 BMW 745i

After about 10-15min waiting period car will start and run find but will go through this shut down cycle again and not crank for another 10-15min i am afraid to drive because it can stop on me in traffic is this a sensor problem.

Asked by for the 2004 BMW 745i