27 “But the man who was mistreating the other pushed Moses aside and said, ‘Who made you ruler and judge over us? 28 Are you thinking of killing me as you killed the Egyptian yesterday?’ 29 When Moses heard this, he fled to Midian, where he settled as a foreigner and had two sons. (Stephen in Acts 7:27-29)
14 The man said, “Who made you ruler and judge over us? Are you thinking of killing me as you killed the Egyptian?” Then Moses was afraid and thought, “What I did must have become known.” 15 When Pharaoh heard of this, he tried to kill Moses, but Moses fled from Pharaoh and went to live in Midian, where he sat down by a well. (Moses in Exodus 2:14-15)
27 By faith he left Egypt, not fearing the king’s anger; he persevered because he saw him who is invisible. (The Hebrews writer in Hebrews 11:27).

So who’s on first? According to Stephen (via Luke), Moses fled to Midian because he was rejected by his own people. The Exodus account has Pharaoh putting out a death warrant on Moses as the precipitating event in his departure. Finally, the Hebrew writer says that it Moses’ faith that caused him to leave Egypt.
So who is right?
They all are.
This is a good example of differing accounts supplementing each other. Let’s start with Luke’s account. He tells us that “Moses thought that his own people would realize that God was using him to rescue them, but they did not,” (v. 25). When he found out otherwise it’s easy to understand his disillusionment and subsequent travel plans. Likewise, when the Exodus account tells us Moses found out that his killing of an Egyptian was known and Pharaoh was after him, we can also understand this as a reason for him leaving Egypt. What the Hebrew writer would have us to see is that while both of these were involved in his decision to go to Midian—they were not the only elements or the most important. The primary reason Moses left Egypt had to do with his faith in God. There’s a couple of ways this could have worked out. Crushed when his role in delivering Israel is unrecognized and concerned about the consequences of killing an Egyptian, would it be strange to think that Moses stopped to pray about his dilemma? He comes to the realization that leaving
Egypt (which he already had in mind), is more importantly, what God has in mind for him.
The second possibility is the same scenario but with the difference that God communicated to Moses that he needed to leave Egypt. The Hebrew writer tells us that he left “by faith.” This expression is often used in Hebrews 11 when there has been communication between God and the people under discussion (v. 7, v. 8, v. 9, v. 11, v. 17, etc.). Although we have no record of anything like this in Exodus, it is not out of place for a NT writer to supplement an OT account. It happens in Acts 7:2-3, where Stephen speaks of Abraham being called while he was in Mesopotamia (Ur of the Chaldeans)— something not mentioned in the Genesis (Genesis 11:27-32). Closer to home, Exodus 2:2-4 attributes Moses being hid to his mother while Hebrews 11:23 gives us the more complete picture that it was both his mother and father. However it happened, this also clarifies the Exodus narrative where we’re told Moses is afraid (v. 14), and he flees from Pharaoh (v. 15). It’s easy to put those two together and conclude that Moses flees Egypt because he’s fearful of Pharaoh but Hebrews 11:27 won’t permit this. But if we allow some time to elapse between these two verses (in which Moses prays or God speaks to him), then he comes to the understanding that leaving Egypt is God’s will and is no longer afraid of Pharaoh. He’s still fleeing him as Exodus 2:15 says, but it’s no longer out of fear—he understands its part of God’s plan. His situation is like that of his parents, who hid Moses during the first three months of his life and yet we’re told they didn’t fear Pharaoh but were acting by faith (Hebrews 11:23). Faith and not fear, is the last word with Moses.