Cast alignment to integer.
Ensure dialogs are closed on deletion.