Fixed Closing excel correctly

by not calling the close excel file if the previous state was a stop
state