Closing the dialog box

Hello!!!

Am I doing something wrong when I close my dialog boxes.

import scriptcontext as sc
import rhinoscriptsyntax as rs
import Rhino
from System.Drawing import Bitmap
import System
import System.Windows.Forms
import System.Drawing

class Form1(System.Windows.Forms.Form):
	def __init__(self):
		self.InitializeComponent() 
		self.ClientSize = System.Drawing.Size(287, 322)
		self.CenterToScreen()
		self.MaximizeBox = False
		self.MinimizeBox = False

	def InitializeComponent(self):
		self.SuspendLayout()
		
		################## LABELS ##################
		
		self._trans = System.Windows.Forms.Label()
		self._trans.Location = System.Drawing.Point(7, 10)
		self._trans.Size = System.Drawing.Size(100, 12)
		self._trans.Text = "Transformations:"
		self.Controls.Add(self._trans)
		
		self.KeyPreview = True
		self.Text = "Test"
		self.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
		self.KeyDown += self.OnKeyDownEvent
		self.Closing += self.OnClosingEvent
		self.ResumeLayout(False)
		# Linkbutton click handler

	def OnKeyDownEvent(self, sender, e):
		finish = e.KeyCode == System.Windows.Forms.Keys.Escape
		if finish:
			self.Close()
		e.Handled = True
	def OnClosingEvent(self, sender, e):
		Rhino.Input.Custom.GetBaseClass.PostCustomMessage("exit")


def Test():

	f = Form1()
	f.Show(Rhino.RhinoApp.MainWindow())
	gs = Rhino.Input.Custom.GetString()
	gs.SetCommandPrompt("press escape to exit")
	gs.AcceptCustomMessage(True)
	gs.Get()
	
	if not f.IsDisposed:
		f.Close()
	
	rs.Command("_line 0,0,0 10,0,0", True)

if __name__ == "__main__":
	Test()
	

Why does this command line not work after the dialog box is closed?

image

Does anyone have any tips?