Prevent potential crash in ns_send_appdefined
These crashes possibly occur due to  [NSApp mainWindow] returning nil when the application is hidden,
and the even is then sent to window number 0 (which perhaps does not exist).

Conflicts:
	src/nsfns.m
	src/nsterm.m