LPS-47273 Add method guards. Don't throw exceptions if everything is already ok

This pr solves random issues with Dumbster fake smtp server, which sometimes starts faster than previous execution stopped, and the socket may be still not closed