Most likely, when you close the lid, your computer is going to sleep. In the hour that passes, your battery goes totally dead and the sleep state is lost, resulting in the "not shut down properly" message. Change it so that when you close the lid, the computer shuts down or hibernates instead (in power settings).