Wrote shutdown method in main.py to handle shutdown procedure

Moved settings use to mainwindow from window.