PyQt5 running in IDLE but not in terminal

import sys
from PyQt5 import QtWidgets

app = QtWidgets.QApplication(sys.argv)
windows = QtWidgets.QWidget()
windows.show()

This code runs fine in IDLE and creates a window. On the other hand, it doesn't seem to do much in terminal. I've tried with "python xyz" and just with "open with python". None of them seem to even produce any feedback; the window just instantly closes. It also seems to be exclusive to my scripts that use PyQt5, all other scripts work fine.

I'm using Windows 10, running python 3.6.4.