Confirm that the handle is closed before freeing it.