I was leaving when he arrived . ( means I had already decided to leave and in the process of leaving when he got in)
I left when he arrived. ( meas I was not in the process of leaving and my leaving happened after he had arrived)
I think you can figure out the difference in the two examples , each of which can be an answer to your questions.
If you have a question about the English language and would like to ask one of our many English teachers and language experts, please click the button below to let us know: