Add termination when opening a file