You can press the spacebar again to close the Quick Look window or tap the close button on the upper left corner of the Quick Look window.