Make close command work correctly