You can switch the engine off whilst in D, but the key wont go all the way round to the 'zero' position and therefore wouldn't be able to remove the key from the barrel.
Need to slide box in to P and then the key will turn that final little bit in order to be removed.
Not sure why anyone would switch off in D and then slide up to P. I always do it the other way round and would have thought that's standard practice for anyone with an autobox?