Fixed bug when window were closing instead of hiding