When a program suddenly quits in OS X without any user direction, it usually means the program has crashed. The system will likely show the crash reporter window that you can submit to Apple to help the developers troubleshoot their code and correct the problem. However, if you are running OS X Lion then you may run into a situation in which applications you have open will close without showing any indication of a problem.
As an example, go ahead and open TextEdit and close any windows that open up. Then go through your Applications folder and launch a number of your applications (or all of them), to have your system fill its available RAM capacity and use the CPU. For many systems, once a number of applications have been opened you will see the TextEdit program suddenly quit and disappear from the Dock, with no warning or crash report. However, if you go to Activity Monitor you will still see TextEdit running as one of the processes in the system.
What the heck is going on?
Applications randomly quitting may be concerning to people, but is in fact a new feature in OS X Lion called Automatic Termination, which helps the system manage situations where system resources are being heavily used. If an open application is not in use, then the OS now supports closing it down so the resources such as RAM and CPU cycles it may be reserving can be transferred to other programs and processes that need them.
While people may wonder about how the system tracks what applications are being used, the process is actually quite simple and abides by three basic criteria:
Application support -- First the program itself will have to be coded to support Application Termination, so the system cannot just arbitrarily terminate an important tool you are using if the programmer does not intend this to be done.
All windows must be closed -- Secondly, the program cannot be using the system's window manger, so any windows for it will need to be closed (minimized does not count). If you have a document or settings window open, then the system assumes you are using the program and will not close it.
Background applications only -- Lastly, the program will need to be in the background and not the foremost "active" application that you are using. This will prevent the program from closing if you merely close all of its windows and having the system immediately shut it down under high-demand situations.
What these criteria set up is a situation where non-essential applications like TextEdit that do not have any documents open can be terminated if needed, to help keep the system running as smoothly as possible for applications that you are using.
Application Termination is not as simple as merely quitting the program. Instead of doing this and immediately relinquishing the program's resources Application Termination will keep the underlying process for the application active, which is why the program still appears in Activity Monitor even though it has been closed. What this allows the system to do is prepare the program process to be killed if necessary, but will keep it in a dormant state as long as possible so it can quickly be relaunched again if desired.