Fixed Hangup error caused by an error of closing a file which was not openned

due to entry to stop state in the state machine