There is no fixed rule, depends a lot on the level of the DD crew, if they're veteran AI or some such 1,5km is too close and 60m too shallow
but if they're early war Green AI you can get fairly close on the surface without being spotted at night, especially when deck's awash, and when I say fairly close I mean 500 meters or so
it's never smart to get too close when submerged though, sometimes you can be at 30m silent running, and stopped and they can still find you from 750 meters away when you thought the DD would just pass you by...
A careful Captain will be able to avoid escorts fairly easily up until 1942 after that... well it gets tougher real quick, and in 1944 it boils down to get detected and you're toast unless you get lucky...