close process when closing the window, solving ui thread locking issue