Use a break point on the "frmMain.Hide();" line and see if nothing stops the code from being executed