The fact that $B$ is closed can be deduced from the following more general (and more peculiar) result:
Proposition. A topological space $(X,\tau)$ is Hausdorff if and only if its diagonal $\Delta_X:=\lbrace (x,x):x\in X\rbrace$ is closed in $X\times X$ (with the product topology).
Proof. Let us write $\mathscr{B}_\Pi:=\lbrace U\times V: U,V\in\tau\rbrace$ to denote the base for the product topology on $X\times X$. Moreover, we write $\mathscr{U}_x:=\lbrace U\in \tau: x\in U\rbrace$ to denote the set of all open neighbourhoods of $x$ in $X$.
Suppose that $\Delta_X$ is closed. Then $X\times X\setminus \Delta_X$ is open. Suppose that $x$ and $y$ are two distinct points in $X$. Then clearly $(x,y)$ is not an element of the diagonal, and thus $(x,y)\in X\times X\setminus \Delta_X$. Since this set is open, we may find a base element $U\times V$ in the base $\mathscr{B}_\Pi$ such that $(x,y)\in U\times V$. These two open sets $U,V\in \tau$ must be disjoint, for otherwise we could find $z\in U\cap V$ which would imply $(z,z)\in U\times V$, so that $U\times V \nsubseteq X\times X\setminus \Delta_X$. Thus $(X,\tau)$ is Hausdorff.
Now suppose that $\Delta_X$ is not closed. This means that $X\times X\setminus \Delta_X$ is not open. This means that we can find $(x,y)\in X\times X\setminus \Delta_X$ so that for all open neighbourhoods $W$ of $(x,y)$ there exists a point $(p,q)\in W$ such that $(p,q)\notin X\times X\setminus \Delta_X$. The fact that $(x,y)\in X\times X\setminus \Delta_X$ means that $x$ and $y$ are distinct. The fact that $(p,q)\notin X\times X\setminus \Delta_X$ means that $p=q$. Since in particular base elements in $\mathscr{B}_\Pi$ are open, we may take $W=U\times V$ for some $U\in \mathscr{U}_x$ and $V\in \mathscr{U}_y$. Thus, the above statement is equivalent to saying that we can find two distinct points $x,y\in X$ so that for every open neighbourhoods $U\in \mathscr{U}_x$ and $V\in\mathscr{U}_y$ there exists a point $(p,p)\in U\times V$. But this means simply that $p\in U\cap V$, and thus $U$ and $V$ are not disjoint. Hence distinct points can not be separated by disjoint open sets, meaning that $(X,\tau)$ is not Hausdorff. The result now follows by contraposition. Q.E.D.
The answer to your question now follows by taking $X=\mathbb{R}$ with the Euclidean topology, which is of course Hausdorff, and noting that $\Delta_\mathbb{R}=B$.
(Edit. See also Faraad Armwood's answer.)