In Hinduism you can have different paths to achieve moksha ( something like going to heaven ) .
This is like you can have different religious views follow different religions and still achieve moksha . You will not be denied heaven only because you followed a different path (religions ), had different views (atheism , agnostic ).
A person may achieve moksha if he did good deed but not prayed to God and a person may be denied moksha even if he prayed all the time but not did any good deed.
If by leaving religion you mean stop praying to God's then people do this all the time .
https://en.m.wikipedia.org/wiki/Atheism_in_Hinduism
I believe in good karma :)
My English is not that good