Yes, they can deny you the right to come back. There is NO law stating that resignation or quitting is ineffective if you had a mental condition at the time you quit or resigned. Quitting a job is not like signing a contract or executing a will; your frame of mind is not a factor in it.