Cmd W closes the document without quitting TextEdit. just tested on lion.
Mac is document-based instead of application-based so closing document doesn't quit the app. it only does if multiple documents doesn't make sense to the application like System Preferences.
> "In general, quit when users close the last open window in your app. [...] If users close the last remaining document window in a document-based app and switch to another app, it’s appropriate to quit the app" (emphasis added).
In TextEdit, close the last document and then _switch to another app_. You're missing the last step.
The TextEdit behavior might actually be the OS silently closing an unused application that implements the necessary hooks for saving state and indicating when clean-up is required on termination. That behavior was introduced in 10.7, but IIRC, can be disabled by the user.