Fixed Bug with window not closing after error