That window opens because you're calling,
window.open()
[
^] and then you're just storing the reference to that window in printWindow variable. Remove that line of code and your pop up window won't come. The remaining objects would remain as they are.
The print window then opens because you call this function too,
printWindow.print();
which can be replaced by this function,
window.print()
;[
^] which does the same thing; shows the print dialog (a preview). Actually, that is not a preview, it is just the settings for your document before sending it to the printer.