Implemented closing processes when corresponding windows are closed.