I'm glad you found my comment helpful!
Could you talk to your husband? He might be less scared if you say it's just thoughts, rather than him finding out when it's got to the point of actual self harm.
Would the guilt and embarrassment be enough of an incentive not to do it? Also a positive incentive would also be your child. Have you got any other good things going on at the moment or in the future that would help to distract from the feelings?