Destroy the window properly so that the process ends the right way.