Windows close button quites App?

So what you need to do first is have the window you want to close be connected to an IBOutlet in the nib. For this example i connected the window to an outlet named “mainWindow”.

The code to add is:
Code:

- (void)awakeFromNib {
        [mainWindow setDelegate:self];
}

- (void)windowWillClose:(NSNotification *)aNotification {
	[NSApp terminate:self];
}


from : http://forums.macrumors.com/showthread.php?t=105229