Most of the time, you should try not to hang on a connection for the lifetime of an application. You should open and close it as needed. If you don't want to close and reopen it as a performance optimization, you don't need to worry about it. Connection pooling for the database driver should handle that.
Anyway, you don't really need to close the connection if the process is going to end. The acquired resources will get released automatically.
If you want to execute code as the form gets closed, you can handle its FormClosing
event. If you want the code to execute after a form is closed, handle its FormClosed
event.