Starting with OS X 10.7 Lion, Apple introduced Auto Save and Resume features that make it so the system will continually save your ongoing work, along with each program's current set of opened windows. This feature allows the system to maintain your workflow in the event of a power failure or crash, or even if you simply quit your program without saving.
To see this feature in action, open TextEdit, Pages, Safari, or another program that is built to work with these services, and create a new document without saving it. Make modifications to it and then choose "Quit" from the application menu. The program will close and when you next reopen it, your documents and their changes should be available for you to access.
If these features are not working in this way, there are several possible reasons for it.
First, it may simply be that the current program does not support the feature. Apple's Resume feature should apply to most applications immediately, but Auto Save requires special implementation from the developer and therefore may not be available in a number of programs, including popular ones like Microsoft Office that have their own autosave features.
Next, be sure you are not closing windows before quitting the program. Sometimes people who are used to Microsoft Windows will click the red button in OS X windows to close the program, but this only closes the window and leaves the program running. Therefore, when the application is finally quit it does not save the window locations for its Resume feature.
Additionally, you may have the system set to close all windows upon quitting an application, which will effectively disable the Resume feature. While by default you need to hold the Option key when quitting to disable Resume, this can be toggled to the default quitting behavior by checking the box to "Close windows when quitting an application" in the General system preferences.
Beyond these settings and oversights, there may be some access problems for the folders the system uses to save a program's Resume and Auto Save data. In these cases, you will need to locate and remove the respective folders so they can be re-created the next time the program is run.
For the Resume feature, if a program is not properly restoring windows that were previously opened before quitting, then try removing the Saved Application State structure for this program. To do this, hold the Option key and choose "Library" from the Go menu in the Finder. Then locate the folder called "Saved Application States" in which you will see each state's data structure in a folder such as "com.apple.Safari.savedstate" for Safari.
Remove this folder, or optionally, if the problem is happening for all programs, remove the entire Saved Application State folder and all of its contents. Do keep in mind that this latter approach will clear the Resume information for all programs you are using.
For problems with the Auto Save feature, you can try removing from this library the folder called "Autosave Information."
One thing to keep in mind is these Auto Save and Resume resources will be kept in a separate location for sandboxed programs like TextEdit and Preview, and any from the Mac App Store. If you go to the Containers folder in the same library directory, you will see folders with names such as "com.apple.TextEdit," which is the container for the TextEdit program. In each container will be a folder called Data that contains a mirror of your user account, including a library folder of its own.
While you can go into each program's container and remove the Auto Save and Resume information for each, another approach is to simply remove the container itself. In doing this you might lose some settings for the program, but upon relaunch the program should recreate these.