Reconfigurable intelligent surfaces (RISs) can improve the capacity of wireless communication links by passively beamforming the impinging signals in desired directions. This feature has been demonstrated both analytically and experimentally for conventional RISs, consisting of independently reflecting elements. To further enhance reconfigurability, a new architecture called beyond-diagonal RIS (BD-RIS) has been proposed. It allows for controllable signal flows between RIS elements, resulting in a non-diagonal reflection matrix, unlike the conventional RIS architecture. Previous studies on BD-RIS-assisted communications have predominantly considered single-antenna transmitters/receivers. One recent work provides an iterative capacity-improving algorithm for multiple-input multiple-output (MIMO) setups but without providing geometrical insights. In this paper, we derive the first closed-form capacity-maximizing BD-RIS reflection matrix for a MIMO channel. We describe how this solution pairs together propagation paths, how it behaves when the signal-to-noise ratio is high, and what capacity is achievable with ideal semi-unitary channel matrices. The analytical results are corroborated numerically.