Do I need to close it one month before it expires, or can I close at any time...say a couple days before it expires?
You don't have to close your account. You can just let your domain and hosting plan expire and keep your account.
$50 off and 3 free domains with code: [color=#CC0000]DH3[/color] [url=http://dreamhost.com/r.cgi?296804/signup|DH3]Sign Up NOW[/url] or More Codes Here
Just be sure to turn off any auto-billing. If you have a domain registered here, you'll either want to manually renew it, or transfer it away.
If you are finished using your account its better to just close it. you can always reopen it later if you like. You can also close it on the last day without issue.