Fixed close index when the index is already closed

 Closes #3601