I would suggest you contact a landlord/tenant attorney and ask him or her this question. You can probably get the answer over the phone for free. I would also suggest you have a peaceful conversation with your landlord and hope for the best.
I am not an attorney and cannot give legal advise, however, my humble take on it is as follows: You stated that you are a "month to month" tenant, I assume that this means there is no written agreement. If so it becomes a "gray" area and hard to give a definitive answer. Theoretically if you are month to month and your rent is paid in full prior to the date that you move out, also assuming you did not damage the apartment, I believe you should be entitled to get your security deposit back. Your landlord may disagree with my perspective and if so you may have a legal battle not worth fighting because the expense would probably be greater than your security deposit anyway.
Madison Estates & Properties, Inc.
Office: (718) 645-1665